-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
37 lines (23 loc) · 821 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# syntax=docker/dockerfile:1
ARG NODE_VERSION=21.5.0
ARG PORT=8080
FROM node:${NODE_VERSION}-alpine AS builder
WORKDIR /usr/src/app
# Copy package files for better caching
COPY package*.json ./
# Install dependencies with Railway-compatible cache mount
RUN --mount=type=cache,id=s/be505659-a9d6-46bd-8bdd-f1831627005c-/root/.npm,target=/root/.npm \
npm ci --omit=dev
# Copy the rest of the application code
COPY . .
# Create a new stage for the runtime
FROM node:${NODE_VERSION}-alpine
ENV NODE_ENV=production
WORKDIR /usr/src/app
# Copy built application from builder stage
COPY --from=builder /usr/src/app ./
USER node
EXPOSE ${PORT}
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:${PORT}/v1/ || exit 1
CMD ["npm", "run", "start"]