Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
fix: updates to Docker images for consistency across Gateway services (
Browse files Browse the repository at this point in the history
…#91)

* fix: updates to Docker images for consistency across Gateway services
- updated CMD to ENTRYPOINT
- eliminated build stage from dev.Dockerfile
- added  '--watch' parameter for use with dev Docker image/docker-compose
- Gave dev docker-compose services an image name so that the 2 app services can share a local image

* fix: add comments and platform to docker-compose file
  • Loading branch information
JoeCap08055 authored Apr 18, 2024
1 parent 5132857 commit 66d585a
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 19 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ jobs:
with:
flavor: |
latest=auto
prefix=api-,onlatest=true
images: |
${{env.DOCKER_HUB_PROFILE}}/${{env.IMAGE_NAME}}
tags: |
Expand All @@ -75,4 +74,4 @@ jobs:
platforms: linux/amd64
push: ${{env.TEST_RUN != 'true'}}
file: ./Dockerfile
tags: ${{ steps.cp-tags.outputs.tags }}
tags: ${{ steps.cp-tags.outputs.tags }}
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 18.16.0
nodejs 20.12.2
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use a multi-stage build for efficiency
FROM node:18 AS builder
FROM node:20 AS builder

WORKDIR /usr/src/app

Expand All @@ -13,17 +13,18 @@ COPY . .
RUN npm run build

# Production stage
FROM node:18
FROM node:20

WORKDIR /usr/src/app

COPY --from=builder /usr/src/app/dist ./dist
COPY package*.json ./

COPY ./lua ./lua

RUN npm install --only=production

EXPOSE 3000
ENV START_PROCESS="api"

ENV START_PROCESS="api"

CMD ["sh", "-c", "if [ \"$START_PROCESS\" = \"api\" ]; then npm run start:api:prod; else npm run start:worker:prod; fi"]
ENTRYPOINT ["npm", "run", "start:${START_PROCESS}:prod"]
2 changes: 1 addition & 1 deletion apps/worker/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ async function bootstrap() {
const app = await NestFactory.createApplicationContext(WorkerModule);
app.enableShutdownHooks();
}
bootstrap();
bootstrap().catch((error) => console.error(error));
11 changes: 7 additions & 4 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
FROM node:18
FROM node:20

WORKDIR /app
COPY . .

RUN npm install
# COPY . .

# RUN npm install

EXPOSE 3000

ENV START_PROCESS="api"

CMD ["sh", "-c", "if [ \"$START_PROCESS\" = \"api\" ]; then npm run start:api; else npm run start:worker; fi"]
ENTRYPOINT npm run start:${START_PROCESS}:watch
25 changes: 20 additions & 5 deletions docker-compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@ services:
- content-publishing-service

frequency:
image: frequencychain/instant-seal-node:latest
image: dsnp/instant-seal-node-with-deployed-schemas:latest
# We need to specify the platform because it's the only image
# built by Frequency at the moment, and auto-pull won't work otherwise
platform: linux/amd64
# Uncomment SEALING_MODE and SEALING_INTERVAL if you want to use interval sealing.
# Other options you may want to add depending on your test scenario.
# environment:
# - SEALING_MODE=interval
# - SEALING_INTERVAL=3
# - CREATE_EMPTY_BLOCKS=true
# Uncomment below if you want to let the chain run and keep all of the historical blocks
# command: --state-pruning=archive
ports:
- 9944:9944
networks:
Expand All @@ -31,16 +42,19 @@ services:
- ipfs_data:/data/ipfs

content-publishing-service-api:
pull_policy: never
image: content-publishing-service
build:
context: .
dockerfile: dev.Dockerfile
tags:
- content-publishing-service:latest
ports:
- 3000:3000
env_file:
- .env.docker.dev
environment:
- START_PROCESS=api
- REDIS_URL=redis://redis:6379
volumes:
- ./:/app
depends_on:
Expand All @@ -51,14 +65,17 @@ services:
- content-publishing-service

content-publishing-service-worker:
pull_policy: never
image: content-publishing-service
build:
context: .
dockerfile: dev.Dockerfile
tags:
- content-publishing-service:latest
env_file:
- .env.docker.dev
environment:
- START_PROCESS=worker
- REDIS_URL=redis://redis:6379
volumes:
- ./:/app
depends_on:
Expand All @@ -75,5 +92,3 @@ volumes:

networks:
content-publishing-service:


4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
"generate-swagger-ui": "redoc-cli bundle swagger.yaml --output=./docs/index.html",
"format": "prettier --write \"apps/**/*.ts\" \"libs/**/*.ts\"",
"start:api": "nest start api",
"start:api:prod": "node dist/apps/api/main.js",
"start:api:watch": "nest start api --watch",
"start:api:prod": "node dist/apps/api/main.js",
"start:worker": "nest start worker",
"start:worker:watch": "nest start worker --watch",
"start:worker:prod": "node dist/apps/worker/main.js",
"start:api:dev": "set -a ; . .env ; nest start api",
"start:worker:dev": "set -a ; . .env ; nest start worker",
Expand Down

0 comments on commit 66d585a

Please sign in to comment.