-
Notifications
You must be signed in to change notification settings - Fork 34
/
Dockerfile
94 lines (58 loc) · 1.56 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#syntax=docker/dockerfile:1.4
# This Dockerfile uses the service folder as context.
# --
# Upstream images
FROM node:20-slim AS node_upstream
FROM nginx:alpine AS nginx_upstream
# --
# Npm image
FROM node_upstream AS npm
# Create app directory
WORKDIR /app
# Source code should be mounted here
VOLUME /app
COPY --link --chmod=755 ./docker-npm-entrypoint.sh /usr/local/bin/docker-npm-entrypoint
ENTRYPOINT [ "docker-npm-entrypoint" ]
CMD [ "--help" ]
# --
# Base image
FROM node_upstream AS app_base
# GitHub context environment variables
ARG GITHUB_REPOSITORY_URL=""
ENV GITHUB_REPOSITORY_URL=${GITHUB_REPOSITORY_URL}
ARG GITHUB_SHA=""
ENV GITHUB_SHA=${GITHUB_SHA}
# Create app directory
WORKDIR /app
# --
# Dev image
FROM app_base AS app_dev
ENV APP_ENV=dev
ENV NODE_ENV=development
# Source code should be mounted here
VOLUME /app
VOLUME /app/node_modules
COPY --link --chmod=755 ./docker-dev-command.sh /usr/local/bin/docker-dev-command
CMD [ "docker-dev-command" ]
# --
# Prod build image
FROM app_base AS app_prod_build
ENV APP_ENV=prod
ENV NODE_ENV=production
# Install dev dependencies, required for build
COPY --link ./app/package*.json ./app/tsconfig*.json ./app/astro.config.mjs .
RUN npm clean-install --include=dev && \
npm cache clean --force
# Copy source code for build
COPY --link ./app .
# Build application
RUN npm run build
# --
# Prod image
FROM nginx_upstream AS app_prod
ENV APP_ENV=prod
ENV NODE_ENV=production
# Set app directory
WORKDIR /usr/share/nginx/html
# Copy built static website files
COPY --from=app_prod_build --link /app/dist .