Skip to content

Commit eba106b

Browse files
author
Test
committed
roll all functionality into 1 container
1 parent c75e20b commit eba106b

6 files changed

Lines changed: 23 additions & 45 deletions

File tree

Dockerfile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ FROM ruby:3.2.2
33

44
# Install dependencies
55
RUN apt-get update -qq
6-
RUN apt-get install -y nodejs postgresql-client libsqlite3-dev build-essential
7-
RUN apt-get install -y default-libmysqlclient-dev libmariadb-dev-compat
6+
RUN apt-get install -y nodejs postgresql-client libsqlite3-dev build-essential
7+
RUN apt-get install -y default-libmysqlclient-dev libmariadb-dev-compat redis-server
88

99
# Set environment variables
1010
ENV RAILS_ENV=production
11-
ENV REDIS_URL=redis://redis:6379/1
11+
ENV REDIS_URL=redis://localhost:6380/1
1212

1313
# Set the working directory in the container
1414
WORKDIR /app
@@ -28,15 +28,13 @@ COPY sidekiq-entrypoint.sh ./sidekiq-entrypoint.sh
2828
COPY rails-entrypoint.sh ./rails-entrypoint.sh
2929

3030
# Make sure the entrypoint scripts are executable
31-
RUN chmod +x entrypoint.sh sidekiq-entrypoint.sh
31+
RUN chmod +x entrypoint.sh sidekiq-entrypoint.sh rails-entrypoint.sh
3232

3333
# Precompile assets for production
3434
RUN SECRET_KEY_BASE=dummy_key RAILS_ENV=production bundle exec rake assets:precompile
3535

36-
# Expose the application port
36+
# Expose the application port and custom Redis port
3737
EXPOSE 3000
38+
EXPOSE 6380
3839

3940
ENTRYPOINT ["./entrypoint.sh"]
40-
41-
# Default command to run the Rails server
42-
CMD bundle exec rails server -b 0.0.0.0 -p 3000

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Before you start, ensure you have the following installed:
135135
4. Start the application with the `SECRET_KEY_BASE` environment variable set:
136136
137137
```bash
138-
SECRET_KEY_BASE=$(bundle exec rake secret) foreman start
138+
foreman start
139139
```
140140
141141
## Configuration

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.17-alpha
1+
1.0.18-alpha

config/credentials.yml.enc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
XPipw3icn3ImGvT+ngdEv55GUi/qsdvDKEFz2ZQsi81kBRowLs54twbRrH1CG6k7NxOr5UcY4yQ/5G/QR1ks35cVJsbWGQHpM04ZsXw8M5RRgl/e3LcCl1qXlVQicm3pEbtlSef0PJxNpxxbUjoDuUv6KjScrLcHZQGeDQabcFHqjsl0YthzeLDA3ojcXTWHLNYeRV8TBvaI2MKgPV2By6jXo5jGQW1kxpTBXzjIvKhDvHyNAzzazkPMBpbFEmF9SGrjvwyL0YcJh7sbRCjguk+ygG7SetazVYyE7Y+0hZ0OAxx0zXiAiZZ+aRXInWrZac9TF7Sq4HI5cN0H/2OPcB86XLt1ochMw9h93fmXlvyRrlbYaCv2P1sXCoX4liHNJwCovkl/Mg+Bgc+7GY3EgfXcwlut--nCVgf0LbKPzPE5Xf--O19Yd363azqX1CIkTmukhw==

docker-compose.yml

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,15 @@
11
services:
2-
web:
2+
app:
33
build: .
4-
entrypoint: ["./rails-entrypoint.sh"]
54
volumes:
6-
- .:/app
75
- ./storage:/app/storage
86
ports:
97
- "3000:3000"
108
environment:
119
RAILS_ENV: production
12-
REDIS_URL: redis://redis:6379/1
10+
REDIS_URL: redis://localhost:6380/1
11+
entrypoint: ["./entrypoint.sh"]
1312
command: ["bundle", "exec", "rails", "server", "-b", "0.0.0.0", "-p", "3000"]
14-
depends_on:
15-
- redis
16-
networks:
17-
- thinknet
18-
19-
worker:
20-
build: .
21-
entrypoint: ["./sidekiq-entrypoint.sh"]
22-
command: ["bundle", "exec", "sidekiq"]
23-
volumes:
24-
- .:/app
25-
- ./storage:/app/storage
26-
environment:
27-
RAILS_ENV: production
28-
REDIS_URL: redis://redis:6379/1
29-
depends_on:
30-
- redis
31-
networks:
32-
- thinknet
33-
34-
redis:
35-
container_name: redis
36-
image: redis:latest
37-
command: ["redis-server", "--bind", "redis", "--port", "6379"]
38-
ports:
39-
- "6379:6379"
4013
networks:
4114
- thinknet
4215

entrypoint.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
#!/bin/bash
22

3-
# Call the first entrypoint script
4-
./rails-entrypoint.sh
3+
# Start Redis server on a different port in the background
4+
redis-server --port 6380 --daemonize yes
55

6-
# Call the second entrypoint script
7-
./sidekiq-entrypoint.sh
6+
if [ -z "$SECRET_KEY_BASE" ]; then
7+
export SECRET_KEY_BASE=$(bin/rails secret)
8+
fi
89

9-
# Finally, execute the command passed to the Docker container
10+
# Start Sidekiq worker in the background
11+
./sidekiq-entrypoint.sh &
12+
bundle exec sidekiq &
13+
14+
15+
# Exit with the status of the last process to exit
1016
exec "$@"

0 commit comments

Comments
 (0)