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

Commit 8131744

Browse files
authored
Published container not working with social-app-template (#93)
The `content-watcher-service` fails to execute when used with `social-app-template` because it can't find `/usr/bin/tini`. ## Solution: `tini` on Alpine lives at `/sbin/tini`. This results in the following error: ```bash 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [NestFactory] Starting Nest application... 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] EventEmitterModule dependencies initialized +22ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BullBoardModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] ConfigHostModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BullBoardFeatureModule dependencies initialized +1ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BullBoardFeatureModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BullBoardFeatureModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BullBoardFeatureModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BullBoardFeatureModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BullBoardFeatureModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BullBoardFeatureModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BullBoardFeatureModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] DiscoveryModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BullBoardRootModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] ConfigModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] ScheduleModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] EventEmitterModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BullModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] ConfigModule dependencies initialized +1ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BullModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BlockchainModule dependencies initialized +2ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BullModule dependencies initialized +3ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BullModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BullModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BullModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BullModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] BullModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] RedisModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] IPFSProcessorModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] ScannerModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] CrawlerModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] PubSubModule dependencies initialized +0ms 2024-07-02 16:22:04 [Nest] 7 - 07/02/2024, 10:22:04 PM LOG [InstanceLoader] ApiModule dependencies initialized +0ms 2024-07-02 16:22:04 /app/node_modules/@nestjs/bullmq/dist/hosts/worker-host.class.js:7 2024-07-02 16:22:04 throw new Error('"Worker" has not yet been initialized. Make sure to interact with worker instances after the "onModuleInit" lifecycle hook is triggered, for example, in the "onApplicationBootstrap" hook.'); 2024-07-02 16:22:04 ^ 2024-07-02 16:22:04 2024-07-02 16:22:04 Error: "Worker" has not yet been initialized. Make sure to interact with worker instances after the "onModuleInit" lifecycle hook is triggered, for example, in the "onApplicationBootstrap" hook. 2024-07-02 16:22:04 at get worker [as worker] (/app/node_modules/@nestjs/bullmq/dist/hosts/worker-host.class.js:7:19) 2024-07-02 16:22:04 at CrawlerService.onModuleDestroy (/app/dist/apps/api/main.js:2602:20) 2024-07-02 16:22:04 at MapIterator.iteratee (/app/node_modules/@nestjs/core/hooks/on-module-destroy.hook.js:22:43) 2024-07-02 16:22:04 at MapIterator.next (/app/node_modules/iterare/lib/map.js:13:39) 2024-07-02 16:22:04 at IteratorWithOperators.next (/app/node_modules/iterare/lib/iterate.js:21:28) 2024-07-02 16:22:04 at Function.from (<anonymous>) 2024-07-02 16:22:04 at IteratorWithOperators.toArray (/app/node_modules/iterare/lib/iterate.js:180:22) 2024-07-02 16:22:04 at callOperator (/app/node_modules/@nestjs/core/hooks/on-module-destroy.hook.js:23:10) 2024-07-02 16:22:04 at callModuleDestroyHook (/app/node_modules/@nestjs/core/hooks/on-module-destroy.hook.js:43:23) 2024-07-02 16:22:04 at NestApplication.callDestroyHook (/app/node_modules/@nestjs/core/nest-application-context.js:233:53) 2024-07-02 16:22:04 2024-07-02 16:22:04 Node.js v20.12.2 ``` ## Changes: - `Dockerfile` rolled back to Node:Ubuntu/Debian base image - Add environment to `docker-compose.yaml`
1 parent a020f68 commit 8131744

File tree

2 files changed

+32
-58
lines changed

2 files changed

+32
-58
lines changed

Dockerfile

Lines changed: 17 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,33 @@
1-
# syntax=docker/dockerfile:1
1+
# Use a multi-stage build for efficiency
2+
FROM node:20 AS builder
23

3-
# Comments are provided throughout this file to help you get started.
4-
# If you need more help, visit the Dockerfile reference guide at
5-
# https://docs.docker.com/go/dockerfile-reference/
6-
7-
# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7
8-
9-
ARG NODE_VERSION=20
10-
11-
################################################################################
12-
# Use node image for base image for all stages.
13-
FROM node:${NODE_VERSION}-alpine as base
14-
15-
# Set working directory for all build stages.
164
WORKDIR /app
175

6+
COPY package*.json ./
187

19-
################################################################################
20-
# Create a stage for installing production dependecies.
21-
FROM base as deps
22-
23-
# Download dependencies as a separate step to take advantage of Docker's caching.
24-
# Leverage a cache mount to /root/.npm to speed up subsequent builds.
25-
# Leverage bind mounts to package.json and package-lock.json to avoid having to copy them
26-
# into this layer.
27-
RUN --mount=type=bind,source=package.json,target=package.json \
28-
--mount=type=bind,source=package-lock.json,target=package-lock.json \
29-
--mount=type=cache,target=/root/.npm \
30-
npm ci --omit=dev
8+
RUN npm ci
319

32-
################################################################################
33-
# Create a stage for building the application.
34-
FROM deps as build
35-
36-
# Download additional development dependencies before building, as some projects require
37-
# "devDependencies" to be installed to build. If you don't need this, remove this step.
38-
RUN --mount=type=bind,source=package.json,target=package.json \
39-
--mount=type=bind,source=package-lock.json,target=package-lock.json \
40-
--mount=type=cache,target=/root/.npm \
41-
npm ci
42-
43-
# Copy the rest of the source files into the image.
4410
COPY . .
45-
# Run the build script.
46-
RUN npm run build
4711

48-
################################################################################
49-
# Create a new stage to run the application with minimal runtime dependencies
50-
# where the necessary files are copied from the build stage.
51-
FROM base as final
12+
# Build the application
13+
RUN npm run build
5214

53-
# Use production node environment by default.
54-
ENV NODE_ENV production
15+
# Production stage
16+
FROM node:20
5517

56-
# Run the application as a non-root user.
57-
USER node
18+
WORKDIR /app
5819

59-
# Copy package.json so that package manager commands can be used.
60-
COPY package.json .
20+
COPY --from=builder /app/dist ./dist
21+
COPY package*.json ./
6122

62-
# Copy the production dependencies from the deps stage and also
63-
# the built application from the build stage into the image.
64-
COPY --from=deps /app/node_modules ./node_modules
65-
COPY --from=build /app/dist ./dist
23+
RUN npm ci --omit=dev
6624

25+
# We want jq and curl in the final image, but we don't need the support files
26+
RUN apt-get update && \
27+
apt-get install -y jq curl tini && \
28+
apt-get clean && \
29+
rm -rf /usr/share/doc /usr/share/man /usr/share/zsh
6730

68-
# Expose the port that the application listens on.
6931
EXPOSE 3000
7032

71-
# Run the application.
7233
ENTRYPOINT ["/usr/bin/tini", "--", "node", "dist/apps/api/main.js"]

docker-compose.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
x-content-watcher-environment: &content-watcher-environment
2+
IPFS_GATEWAY_URL: 'https://ipfs:8080/ipfs/[CID]'
3+
FREQUENCY_URL: 'ws://frequency:9944'
4+
STARTING_BLOCK: 1
5+
REDIS_URL: 'redis://redis:6379'
6+
BLOCKCHAIN_SCAN_INTERVAL_MINUTES: 1
7+
QUEUE_HIGH_WATER: 1000
8+
WEBHOOK_FAILURE_THRESHOLD: 4
9+
WEBHOOK_RETRY_INTERVAL_SECONDS: 10
10+
API_PORT: 3000
11+
CAPACITY_LIMIT: '{"type":"percentage", "value":80}'
12+
IPFS_ENDPOINT: 'http://ipfs:5001'
13+
114
services:
215
redis:
316
image: redis:latest
@@ -82,8 +95,8 @@ services:
8295
dockerfile: dev.Dockerfile
8396
tags:
8497
- content-watcher-service:latest
85-
env_file:
86-
- .env.docker.dev
98+
environment:
99+
<< : *content-watcher-environment
87100
ports:
88101
- 3000:3000
89102
volumes:

0 commit comments

Comments
 (0)