-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathContainerfile
75 lines (55 loc) · 1.9 KB
/
Containerfile
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
# syntax=docker/dockerfile:latest
# Torrust Index GUI
## Su Exe Compile
FROM docker.io/library/gcc:bookworm as gcc
COPY ./contrib/dev-tools/su-exec/ /usr/local/src/su-exec/
RUN cc -Wall -Werror -g /usr/local/src/su-exec/su-exec.c -o /usr/local/bin/su-exec; chmod +x /usr/local/bin/su-exec
## Builder Image
FROM node:21-bookworm as builder
RUN mkdir -p /app
WORKDIR /app
## Build dependencies
FROM builder as dependencies
COPY package.json .
COPY package-lock.json .
RUN npm install-clean
## Build application
FROM dependencies as test
ARG API_BASE_URL=http://localhost:3001/v1
ENV API_BASE_URL=${API_BASE_URL}
COPY . .
RUN npm run build
## Runtime
FROM gcr.io/distroless/nodejs20-debian12:debug as runtime
RUN ["/busybox/cp", "-sp", "/busybox/sh","/busybox/cat","/busybox/ls","/busybox/env", "/bin/"]
COPY --from=gcc --chmod=0555 /usr/local/bin/su-exec /bin/su-exec
ARG USER_ID=1000
ARG NUXT_PUBLIC_API_BASE0=http://localhost:3001/v1
ARG NITRO_HOST=::
ARG NITRO_PORT=3000
ENV TZ=Etc/UTC
ENV USER_ID=${USER_ID}
ENV NUXT_PUBLIC_API_BASE=${NUXT_PUBLIC_API_BASE}
ENV NITRO_HOST=${NITRO_HOST}
ENV NITRO_PORT=${NITRO_PORT}
EXPOSE $NITRO_PORT/tcp
RUN mkdir -p /var/log/torrust/tracker
ENV ENV=/etc/profile
COPY --chmod=0555 ./share/container/entry_script_sh /usr/local/bin/entry.sh
COPY --chmod=0555 ./share/container/health_check.js /usr/local/bin/health_check.js
VOLUME ["/var/log/torrust/index-gui"]
ENV RUNTIME="runtime"
ENTRYPOINT ["/usr/local/bin/entry.sh"]
## Torrust-Index-GUI (debug)
FROM runtime as debug
ENV RUNTIME="debug"
COPY --from=test /app/.output /app/.output
RUN env
CMD ["sh"]
## Torrust-Index-GUI (release) (default)
FROM runtime as release
ENV RUNTIME="release"
COPY --from=test /app/.output /app/.output
HEALTHCHECK --interval=5s --timeout=5s --start-period=3s --retries=3 \
CMD /nodejs/bin/node /usr/local/bin/health_check.js ${NITRO_PORT} || exit 1
CMD [ "/nodejs/bin/node", "/app/.output/server/index.mjs" ]