-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile.deploy
85 lines (68 loc) · 2.9 KB
/
Dockerfile.deploy
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
## BUILDER ##
FROM node:18-alpine AS base
# Install dependencies only when needed
FROM base AS deps
WORKDIR /app
RUN apk add --no-cache libc6-compat unzip \
&& curl -fsSL https://bun.sh/install | sh
# Install dependencies based on the preferred package manager
COPY docking-station-app/package.json docking-station-app/package-lock.json ./
RUN npm install
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY docking-station-app .
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED 1
RUN npm run build
## BUILDER ##
## RUNNER ##
# Production image, copy all the files and run next
FROM python:3.12-slim AS runner
WORKDIR /app
ENV NODE_ENV production
ENV WEB_PORT 3000
ENV SERVER_PORT 3001
EXPOSE ${WEB_PORT}
EXPOSE ${SERVER_PORT}
USER root
# get unzip tool for extracting regctl
COPY --from=builder /usr/bin/unzip /usr/bin/unzip
# COPY --from=builder /usr/local/lib/node_modules/concurrently/dist/bin /usr/local/lib/node_modules/concurrently/dist/bin
# COPY --from=builder /usr/local/bin/concurrently /usr/local/bin/concurrently
# install node
# install curl
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends npm curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# install concurrently package for running multiple commands: https://www.npmjs.com/package/concurrently
# install docker
# install regctl: https://github.com/regclient/regclient
RUN npm install --g concurrently \
&& curl -fsSL https://get.docker.com | bash \
&& curl -L https://github.com/regclient/regclient/releases/latest/download/regctl-linux-amd64 > /usr/bin/regctl \
&& chmod 755 /usr/bin/regctl
RUN mkdir -p /app/docking-station-app/.next \
&& mkdir -p /app/logs /app/config /app/data \
&& ln -snf /app/config /config \
&& ln -snf /app/data /data \
&& ln -snf /app/logs /logs
# Install python dependencies
COPY ./docking-station-app/requirements.txt /app/docking-station-app/requirements.txt
COPY ./docking-station-app/src/app/api /app/docking-station-app/src/app/api
RUN export PYTHONDONTWRITEBYTECODE=1 \
&& python3 -m pip install --no-cache-dir -r /app/docking-station-app/requirements.txt
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder /app/public /app/docking-station-app/public
COPY --from=builder /app/.next/standalone /app/docking-station-app/
COPY --from=builder /app/.next/static /app/docking-station-app/.next/static
COPY --chmod=777 settings.template.yml /app/settings.template.yml
COPY --chmod=777 entrypoint.sh /app/entrypoint.sh
CMD ["/bin/bash", "/app/entrypoint.sh"]
## RUNNER ##