Skip to content

Commit b0301d7

Browse files
fix(docker): make docker-compose.test.yml work for downstream projects (#3324)
* fix(docker): make docker-compose.test.yml work for downstream projects Closes #3319 * fix(docker): use npm ci for deterministic builds and set runtime NODE_ENV
1 parent 98b2b8e commit b0301d7

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ USER node
77
WORKDIR /home/node
88

99
# Install app dependencies & setup
10+
ARG NODE_ENV=production
11+
ENV NODE_ENV=${NODE_ENV}
1012
COPY --chown=node:node package*.json ./
11-
RUN npm install --production
13+
RUN if [ "$NODE_ENV" = "test" ]; then npm ci --include=dev; else npm ci --omit=dev; fi
1214
COPY --chown=node:node . .
1315

1416
# Expose

docker-compose.test.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ services:
1010
retries: 5
1111

1212
test:
13-
build: .
13+
build:
14+
context: .
15+
args:
16+
NODE_ENV: test
1417
command: npm run test:all
1518
depends_on:
1619
mongo:
1720
condition: service_healthy
1821
environment:
1922
NODE_ENV: test
2023
DEVKIT_NODE_db_uri: mongodb://mongo:27017/NodeTest
24+
DEVKIT_NODE_api_host: 0.0.0.0
25+
DEVKIT_NODE_trust_proxy: "true"
26+
DEVKIT_NODE_cors_origin: "['http://localhost:8080']"

0 commit comments

Comments
 (0)