Skip to content

Commit 5a7cca9

Browse files
Fix #4497: Dev Setup: Make worker and statsd containers optional(#4498)
* Make worker and statsd optional in development setup - Updated to use profiles for and - Updated to document how to start optional containers using profiles * update Dockerfile of nodejs in dev mode --------- Co-authored-by: Rishabh Jain <rishabhjain2018@gmail.com>
1 parent dab3f1e commit 5a7cca9

3 files changed

Lines changed: 59 additions & 13 deletions

File tree

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,25 @@ The steps are:
5454
docker-compose up --build
5555
```
5656

57+
By default, this starts only the required services (`db`, `sqs`, and `django`).
58+
If you need **worker** services, start them using:
59+
60+
```
61+
docker-compose --profile worker up --build
62+
```
63+
64+
If you need **statsd-exporter**, start it using:
65+
66+
```
67+
docker-compose --profile statsd up --build
68+
```
69+
70+
To start **both optional services**, use:
71+
72+
```
73+
docker-compose --profile worker --profile statsd up --build
74+
```
75+
5776
4. That's it. Open web browser and hit the URL [http://127.0.0.1:8888](http://127.0.0.1:8888). Three users will be created by default which are listed below -
5877
5978
**SUPERUSER-** username: `admin` password: `password`

docker-compose.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: "3"
21
services:
32
db:
43
image: postgres:10.4
@@ -23,31 +22,38 @@ services:
2322
depends_on:
2423
- db
2524
- sqs
26-
- statsd-exporter
2725
volumes:
2826
- .:/code
2927

3028
worker:
3129
env_file:
3230
- docker/dev/docker.env
31+
image: my_custom_worker_image # Default image used if not built
3332
build:
3433
context: ./
3534
dockerfile: docker/dev/worker/Dockerfile
35+
x-enabled: ${BUILD_WORKER:-false} # Only build if BUILD_WORKER=true
3636
depends_on:
3737
- django
3838
volumes:
3939
- .:/code
40+
profiles:
41+
- worker # Only built when this profile is specified
4042

4143
worker_py3_8:
4244
env_file:
4345
- docker/dev/docker.env
46+
image: my_custom_worker_py3_8_image # Default image used if not built
4447
build:
4548
context: ./
4649
dockerfile: docker/dev/worker_py3.8/Dockerfile
50+
x-enabled: ${BUILD_WORKER:-false}
4751
depends_on:
4852
- django
4953
volumes:
5054
- .:/code
55+
profiles:
56+
- worker
5157

5258
nodejs:
5359
hostname: nodejs
@@ -67,9 +73,15 @@ services:
6773
statsd-exporter:
6874
hostname: statsd
6975
image: prom/statsd-exporter:latest
76+
build:
77+
context: ./
78+
dockerfile: docker/dev/statsd-exporter/Dockerfile
79+
x-enabled: ${BUILD_STATSD:-false} # Only build if BUILD_STATSD=true
7080
command:
7181
- '--log.level=info'
7282
- '--web.telemetry-path=/statsd/metrics'
7383
ports:
7484
- '9125:9125'
7585
- '9102:9102'
86+
profiles:
87+
- statsd # Only built when this profile is specified

docker/dev/nodejs/Dockerfile

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
FROM node:14.20.0
2-
3-
# install chrome for protractor tests
4-
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
5-
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
6-
RUN apt-get update && apt-get install -yq google-chrome-stable
7-
1+
# Base stage with common dependencies
2+
FROM node:14.20.0 AS base
83
WORKDIR /code
94

105
# Add dependencies
@@ -16,16 +11,36 @@ ADD ./karma.conf.js /code
1611

1712
# Install Prerequisites
1813
RUN npm install -g bower gulp gulp-cli
19-
2014
RUN npm link gulp
21-
2215
RUN npm cache clean -f
2316
RUN npm install
2417
RUN npm install -g karma-cli
2518
RUN npm install -g qs
2619
RUN bower install --allow-root
27-
RUN apt-get install -y libxss1
2820

21+
# AMD64-specific stage
22+
FROM base AS amd64
23+
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
24+
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
25+
RUN apt-get update && apt-get install -yq google-chrome-stable libxss1
26+
27+
# ARM64-specific stage
28+
FROM base AS arm64
29+
# Using newer keyring method for better compatibility
30+
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /usr/share/keyrings/google-chrome.gpg
31+
# Add a message for users on ARM64
32+
RUN echo "Chrome installation skipped on ARM64 architecture" && \
33+
# Create a placeholder chrome executable that exits gracefully
34+
echo '#!/bin/bash' > /usr/bin/google-chrome && \
35+
echo 'echo "Warning: Running on ARM64 architecture. Chrome is not available."' >> /usr/bin/google-chrome && \
36+
echo 'echo "For full Chrome functionality, rebuild with: docker build --platform=linux/amd64 ."' >> /usr/bin/google-chrome && \
37+
echo 'exit 0' >> /usr/bin/google-chrome && \
38+
chmod +x /usr/bin/google-chrome && \
39+
apt-get update && apt-get install -yq libxss1
40+
41+
# Final stage - automatically selects the right architecture
42+
FROM ${TARGETARCH:-amd64}
43+
44+
# Set common command and expose port
2945
CMD ["gulp", "dev:runserver"]
30-
3146
EXPOSE 8888

0 commit comments

Comments
 (0)