-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
57 lines (41 loc) · 1.25 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Stage 1: Base image
FROM node:18-alpine as base
# Required for dependencies coming from git
RUN apk add --no-cache git
# Stage 2: Builder image
FROM base as builder
# Set the working directory
WORKDIR /app
# Install dependencies
COPY package.json yarn.lock ./
RUN yarn install --immutable --immutable-cache --inline-builds --production=false
# Copy source
COPY . .
# Build the application
RUN yarn build
# Stage 3: Final production image
FROM base
# Set the working directory
WORKDIR /app
# Install only production dependencies
COPY package.json yarn.lock ./
RUN yarn install --immutable --immutable-cache --inline-builds --production \
&& yarn cache clean
# Copy built artifacts from builder stage
COPY --from=builder /app/dist/ ./dist/
COPY --from=builder /app/database/ ./dist/database/
COPY --from=builder /app/public/ ./public/
# Docker build args and environment variables
ARG VERSION
ENV VERSION=${VERSION}
ARG ENVIRONMENT
ENV ENVIRONMENT=${ENVIRONMENT}
# Set default environment variables
ENV NODE_ENV=production
ENV TZ=Etc/GMT
# Expose application port
EXPOSE 3000
# Start the server
CMD ["sh", "-c", "yarn start"]
# Healthcheck
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD wget -qO- http://localhost:3000/ping || exit 1