Skip to content

Commit cd4e6f5

Browse files
fix: update Dockerfile to run database migrations in CMD (#422)
* fix: update Dockerfile to run database migrations in CMD * chore: enhance Dockerfile with dumb-init for signal handling and improve artifact copying --------- Co-authored-by: Ricardo Cabral <me@ricardocabral.io>
1 parent 0209bff commit cd4e6f5

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

Dockerfile.railwayapp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ ADD migrations /build/migrations
2323

2424
RUN npm install -g knex@2.4.0 && npm install --quiet
2525

26-
RUN npm run db:migrate
27-
2826
COPY . .
2927

3028
RUN npm run build
3129

3230
FROM node:24-alpine
3331

32+
# Install dumb-init for proper signal handling
33+
RUN apk add --no-cache dumb-init
34+
3435
ARG PORT
3536
ARG PGHOST
3637
ARG PGPORT
@@ -71,12 +72,19 @@ LABEL org.opencontainers.image.licenses=MIT
7172

7273
WORKDIR /app
7374

75+
# Copy runtime artifacts and configuration
7476
COPY --from=build /build/dist .
77+
COPY --from=build /build/package.json /build/package-lock.json ./
78+
COPY --from=build /build/knexfile.js ./
79+
COPY --from=build /build/migrations ./migrations
80+
COPY --from=build /build/seeds ./seeds
7581

76-
RUN npm install --omit=dev --quiet
82+
RUN npm install --omit=dev --quiet && npm install -g knex@2.4.0
7783

7884
USER 1000:1000
7985

8086
RUN mkdir -p $NOSTR_CONFIG_DIR
8187

82-
CMD ["node", "src/index.js"]
88+
ENTRYPOINT ["dumb-init", "--"]
89+
90+
CMD ["sh", "-c", "npm run db:migrate && node src/index.js"]

0 commit comments

Comments
 (0)