Skip to content

Commit 3a15952

Browse files
authored
add dev stage to dockerfile (#1953)
* add dev stage to dockerfile * update readme * bump ruby version for docker contianers
1 parent 362e26a commit 3a15952

4 files changed

Lines changed: 84 additions & 5 deletions

File tree

Dockerfile

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
############################################
22
# 🏗 Stage 1 – build gems + assets
33
############################################
4-
FROM ruby:3.3.5-slim AS builder
4+
FROM ruby:3.3.8-slim AS builder
55

66
# Essential OS packages (compile + JS pipeline)
77
# RUN apt-get update
@@ -29,9 +29,9 @@ RUN chmod +x /usr/local/bin/docker_entrypoint.sh
2929
RUN RAILS_ENV=production DISABLE_DB=true SECRET_KEY_BASE=precompile_only bundle exec rake assets:precompile
3030

3131
################################################
32-
# 🏃‍♂️ Stage 2 – runtime only (tiny image)
32+
# 🏃‍♂️ Stage 2 – production image
3333
################################################
34-
FROM ruby:3.3.5-slim
34+
FROM ruby:3.3.8-slim AS prod
3535

3636
# ➜ install only the shared lib, not the dev headers
3737
RUN --mount=type=cache,target=/var/cache/apt \
@@ -62,4 +62,41 @@ USER app
6262

6363
# Puma listens on 0.0.0.0:3000
6464
EXPOSE 3000
65-
CMD ["/usr/local/bin/docker_entrypoint.sh"]
65+
CMD ["/usr/local/bin/docker_entrypoint.sh"]
66+
67+
############################################
68+
# 🏗 Stage 3 – development environment
69+
############################################
70+
FROM ruby:3.3.8-slim AS dev
71+
72+
# Essential OS packages (compile + JS pipeline)
73+
RUN apt-get update && \
74+
apt-get install -y --no-install-recommends \
75+
curl \
76+
build-essential libpq-dev git \
77+
nodejs npm tzdata
78+
79+
# Copy only Gemfiles to install dependencies early
80+
WORKDIR /app
81+
COPY Gemfile Gemfile.lock ./
82+
RUN bundle install --jobs 4 --retry 3
83+
84+
# Environment setup for development
85+
ENV RAILS_ENV=development \
86+
BUNDLE_WITHOUT='test' \
87+
PORT=3000
88+
89+
# App working directory
90+
WORKDIR /app
91+
92+
# Mount source files for hot reloading
93+
COPY . .
94+
95+
# Install foreman for managing processes
96+
RUN gem install foreman
97+
98+
# Expose port for development
99+
EXPOSE 3000
100+
101+
# Command to start the application with foreman
102+
CMD ["foreman", "start"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Using docker is the fastest way to stand up Cypress for deployment and developme
2121

2222
2. Spin up app with `docker compose up -d --build`
2323

24-
*NOTE: comment/uncomment `- RAILS_ENV=development` in docker-compose.yml to switch between development and production environments. Development environment enables hot-reloading of code changes.*
24+
*NOTE: To spin up Cypress development environment, with hot-reloading enabled for code changes, run `docker compose -f docker-compose.dev.yml up -d`*
2525

2626
Reporting Issues
2727
================

docker-compose.dev.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
services:
2+
nginx:
3+
image: nginx:1.28-alpine
4+
ports:
5+
- "80:80"
6+
- "443:443"
7+
environment:
8+
- USE_SSL=true
9+
volumes:
10+
- ./docker/nginx:/docker/nginx:ro
11+
- ./docker/nginx/nginx-init.sh:/docker-entrypoint.d/nginx-init.sh:ro
12+
cypress:
13+
image: cypress:dev
14+
platform: linux/amd64
15+
build:
16+
context: .
17+
target: dev
18+
volumes:
19+
- cypress-vol:/app/public/data
20+
- ./docker/config:/docker/config
21+
- ./app:/app/app:ro
22+
- ./config:/app/config:ro
23+
- ./lib:/app/lib:ro
24+
environment:
25+
- MONGO_PORT_27017_TCP_ADDR=mongodb
26+
- MONGO_PORT_27017_TCP_PORT=27017
27+
- CQM_EXECUTION_SERVICE_HOST=cqm-execution-service
28+
- SECRET_KEY_BASE=insecure_5131595823afbc3e6af90151ea8991fb3fc7d66e2a352f7664e6ef83bf572cfce8669ce542793b1597f3266706e4bc1ae3dee7f9b5023496ac21990
29+
- RAILS_ENV=development
30+
mongodb:
31+
image: mongo:8.0.9
32+
volumes:
33+
- mongo-data:/data/db
34+
- ./mongo:/etc/mongo
35+
command: --config=/etc/mongo/docker_mongod.conf
36+
cqm-execution-service:
37+
image: mitrehealthdocker/cqm-execution-service:cypress_v7
38+
platform: linux/amd64
39+
volumes:
40+
cypress-vol:
41+
mongo-data:

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ services:
1717
# Uncomment build section below to build a new image from source
1818
# build:
1919
# context: .
20+
# target: prod
2021
volumes:
2122
- cypress-vol:/app/public/data
2223
- ./docker/config:/docker/config

0 commit comments

Comments
 (0)