-
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathDockerfile
More file actions
92 lines (76 loc) · 3.08 KB
/
Dockerfile
File metadata and controls
92 lines (76 loc) · 3.08 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
# Use the official Node LTS slim image as the base
FROM node:lts-slim AS base
# Set environment variables
ENV TZ="Etc/UTC" \
PUID=1000 \
PGID=1000 \
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
NPM_CONFIG_PREFIX=/home/node/.npm-global \
PNPM_HOME=/pnpm \
SERVER_PORT=8080 \
SERVER_HTTPS_PORT=8443 \
YES=yes \
PATH="/home/node/.npm-global/bin:/pnpm:$PATH"
# Create necessary directories with appropriate permissions
RUN mkdir -p /config /files /media /logs /db /plugins /savefiles \
# Enable non-free and contrib repositories for Debian-based package installations
&& sed -i -e 's/ main/ main non-free non-free-firmware contrib/g' /etc/apt/sources.list.d/debian.sources \
# Update package list and install necessary dependencies
&& apt update \
&& apt install -y --no-install-recommends \
build-essential \
ca-certificates \
curl \
g++ \
make \
p7zip-full \
p7zip-rar \
postgresql-common \
python-is-python3 \
python3 \
sudo \
# Install the latest PostgreSQL client from the PostgreSQL Global Development Group (PGDG)
# pg_dump is backward-compatible, so the latest version works with all prior server versions
&& /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh \
&& apt-get update \
&& apt install -y --no-install-recommends postgresql-client-$(apt-cache search --names-only '^postgresql-client-[0-9]+$' | sort -t'-' -k3 -n | tail -1 | grep -oP '\d+$') \
# Clean up to reduce image size
&& apt clean && rm -rf /var/lib/apt/lists/* \
# Install PNPM package manager globally
&& npm i -g pnpm@^10.29.3
# Set working directory for the application
WORKDIR /app
# ---- Build Stage ----
FROM base AS build
# Copy dependency files and install dependencies
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
# Copy application source code and build the project
COPY . .
RUN pnpm run build
# ---- Production Dependencies Stage ----
FROM base AS prod-deps
# Copy dependency files and install only production dependencies
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --prod --frozen-lockfile
# ---- Release Stage ----
FROM base AS release
# Set the environment to production mode
ENV NODE_ENV=production
# Copy dependency files (ensuring same versions as build)
COPY package.json pnpm-lock.yaml ./
# Copy built application and production dependencies
COPY --from=build --chown=node:node /app/dist ./dist
COPY --from=prod-deps --chown=node:node /app/node_modules ./node_modules
COPY --chown=node:node entrypoint.sh /usr/local/bin/
RUN chown -R node:node /app/dist /config /files /media /logs /db /plugins /savefiles \
&& chmod -R 777 /app/dist /config /files /media /logs /db /plugins /savefiles \
&& chmod +x /usr/local/bin/entrypoint.sh
# Expose the server ports (HTTP and HTTPS)
EXPOSE ${SERVER_PORT}/tcp
EXPOSE ${SERVER_HTTPS_PORT}/tcp
# Add a health check for the service
HEALTHCHECK --start-period=300s CMD curl -f http://localhost:${SERVER_PORT}/api/status || exit 1
# Set entrypoint and default command
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["dist/src/main"]