-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
120 lines (99 loc) · 2.48 KB
/
Dockerfile
File metadata and controls
120 lines (99 loc) · 2.48 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# -------------------------------
# BUILD STAGE
# -------------------------------
FROM node:24-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
RUN npm run docs
# -------------------------------
# PRODUCTION STAGE
# -------------------------------
FROM node:24-alpine AS app
# useful alpine ops addons
RUN apk add --no-cache \
su-exec \
tzdata \
bash \
curl \
git \
zip \
unzip \
rsync \
openssh-client \
jq \
yq \
vips \
miller \
age \
lua
# more useful ops tools to be added here (rebuild of docker image required), e.g.
# - rclone \
# - python3 \
# environment variables
ENV CROPS_CONFIG_DIR=/config \
CROPS_TEMP_DIR=/data/temp \
CROPS_LOG_DIR=/data/logs \
CROPS_SOURCE_ROOT=/io/source \
CROPS_TARGET_ROOT=/io/target \
CROPS_SOURCE_2_ROOT=/io/source2 \
CROPS_TARGET_2_ROOT=/io/target2 \
CROPS_SOURCE_3_ROOT=/io/source3 \
CROPS_TARGET_3_ROOT=/io/target3 \
CROPS_HOST=0.0.0.0 \
CROPS_PORT=8083 \
NODE_ENV=production \
PUID=1001 \
PGID=1001
# create folders
RUN mkdir -p \
${CROPS_CONFIG_DIR} \
${CROPS_TEMP_DIR} \
${CROPS_LOG_DIR} \
${CROPS_SOURCE_ROOT} \
${CROPS_TARGET_ROOT} \
${CROPS_SOURCE_2_ROOT} \
${CROPS_TARGET_2_ROOT} \
${CROPS_SOURCE_3_ROOT} \
${CROPS_TARGET_3_ROOT}
WORKDIR /app
# copy essential files
COPY ./config ./config
COPY LICENSE ./
COPY package*.json ./
# install node modules & remove cache
RUN npm ci --omit=dev && npm cache clean --force
# copy dist files from build stage
COPY --from=builder /app/dist ./dist
# copy bootstrap
COPY ./docker/bootstrap.sh /usr/local/bin/bootstrap.sh
RUN chmod +x /usr/local/bin/bootstrap.sh
# expose volumes
VOLUME ${CROPS_CONFIG_DIR} \
${CROPS_TEMP_DIR} \
${CROPS_LOG_DIR} \
${CROPS_SOURCE_ROOT} \
${CROPS_TARGET_ROOT} \
${CROPS_SOURCE_2_ROOT} \
${CROPS_TARGET_2_ROOT} \
${CROPS_SOURCE_3_ROOT} \
${CROPS_TARGET_3_ROOT}
# expose port
EXPOSE ${CROPS_PORT}
# configure healthcheck
HEALTHCHECK --interval=30s \
--timeout=3s \
--retries=2 \
CMD curl -fsS http://localhost:${CROPS_PORT}/health || exit 1
# entrypoint (creates)
ENTRYPOINT ["/usr/local/bin/bootstrap.sh"]
# define entry
CMD ["node", "./dist/server.js"]
# -------------------------------
# DOCUMENTATION STAGE
# -------------------------------
FROM nginx:alpine AS docs
# copy dist files from build stage
COPY --from=builder /app/build/docs /usr/share/nginx/html