Skip to content

Commit cd91092

Browse files
committed
chore: setup docker for development #118
1 parent ca209dd commit cd91092

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

Dockerfile.dev

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Use Ruby 3.x with Alpine as base image for smaller size
2+
FROM ruby:3.4.1-alpine
3+
4+
# Set environment variables for Rails
5+
ENV RAILS_ENV=development \
6+
RACK_ENV=development \
7+
BUNDLE_PATH=/usr/local/bundle \
8+
BUNDLE_JOBS=4 \
9+
BUNDLE_RETRY=3
10+
11+
# Install system dependencies and development tools
12+
RUN apk add --no-cache \
13+
build-base \
14+
postgresql-dev \
15+
git \
16+
tzdata \
17+
bash
18+
19+
# Create and set working directory
20+
WORKDIR /app
21+
22+
# Install Ruby dependencies
23+
COPY Gemfile Gemfile.lock ./
24+
RUN bundle install
25+
26+
# Add bind mount point for code
27+
VOLUME /app
28+
29+
# Port used by Rails server
30+
EXPOSE 3000
31+
32+
# Configure entrypoint to run Rails
33+
#COPY entrypoint.dev.sh /usr/bin/
34+
RUN #chmod +x /usr/bin/entrypoint.dev
35+
ENTRYPOINT ["./bin/docker-entrypoint.dev"]
36+
37+
# Start Rails server by default
38+
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]

bin/docker-entrypoint.dev

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash -e
2+
3+
# Remove any existing server.pid file
4+
rm -f /app/tmp/pids/server.pid
5+
6+
# Install new gems if any
7+
bundle check || bundle install
8+
9+
# If running the rails server then create or migrate existing database
10+
./bin/rails db:prepare
11+
12+
# Execute the main command passed to docker run
13+
exec "$@"

docker-compose.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
version: '3'
2+
3+
services:
4+
app:
5+
build:
6+
dockerfile: Dockerfile.dev
7+
ports:
8+
- "3000:3000"
9+
volumes:
10+
- ./:/app
11+
- ./config:/app/config
12+
environment:
13+
RAILS_ENV: development
14+
DATABASE_USER: postgres
15+
DATABASE_PASSWORD: password
16+
DATABASE_NAME: skillrx_development
17+
DATABASE_PORT: 5432
18+
DATABASE_HOST: db
19+
depends_on:
20+
- db
21+
22+
db:
23+
image: postgres:17-alpine
24+
ports:
25+
- "5432:5432"
26+
volumes:
27+
- db_data:/var/lib/postgresql/data
28+
environment:
29+
POSTGRES_USER: postgres
30+
POSTGRES_PASSWORD: password
31+
POSTGRES_DATABASE: skillrx_development
32+
33+
volumes:
34+
db_data:
35+
36+
networks:
37+
default:
38+
name: skillrx_network

0 commit comments

Comments
 (0)