-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
60 lines (44 loc) · 1.32 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
ARG USER=vbot
ARG APP_DIR=/home/${USER}/app
ARG NODE_VERSION=18
# build stage
FROM docker.io/library/node:${NODE_VERSION}-slim AS builder
ARG USER
ARG APP_DIR
RUN useradd "$USER" --create-home;
RUN mkdir -p "$APP_DIR"; \
chown "$USER" "$APP_DIR"; \
chown "$USER" /usr/local/lib/node_modules;
WORKDIR ${APP_DIR}
COPY package*.json ${APP_DIR}/
RUN npm install
COPY . ${APP_DIR}/
RUN npm run build
RUN rm -rf node_modules
# run stage
FROM docker.io/library/node:${NODE_VERSION}-slim as runner
LABEL \
maintainer="[email protected]" \
org.opencontainers.image.source="https://github.com/Virginity-Bot/virginity-bot" \
org.opencontainers.image.title="virginity-bot3" \
org.opencontainers.image.description="A Discord Bot to track peoples' time in VC." \
org.opencontainers.image.licenses="AGPL-3.0"
ARG USER
ARG APP_DIR
RUN DEBIAN_FRONTEND=noninteractive apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install \
curl
RUN useradd "$USER" --create-home;
WORKDIR ${APP_DIR}
COPY package*.json ${APP_DIR}/
RUN npm install --omit=dev
ENV MIKRO_ORM_CACHE_DIR=/tmp/mikroorm-cache
ARG PORT=3000
EXPOSE $PORT/tcp
ENV PORT $PORT
# Ensure Chalk outputs colors
ENV FORCE_COLOR 1
COPY --from=builder ${APP_DIR} ${APP_DIR}/
USER ${USER}
CMD npm run start:prod
HEALTHCHECK CMD curl --fail localhost:${PORT}/health || exit 1