Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
117 lines (96 loc) · 3.92 KB
/
Copy pathDockerfile
File metadata and controls
117 lines (96 loc) · 3.92 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
# syntax=docker/dockerfile:1.12
# Please see https://docs.docker.com/engine/reference/builder for information about
# the extended buildx capabilities used in this file.
# Make sure multiarch TARGETPLATFORM is available for interpolation
# See: https://docs.docker.com/build/building/multi-platform/
ARG TARGETPLATFORM=${TARGETPLATFORM}
ARG BUILDPLATFORM=${BUILDPLATFORM}
ARG BASE_REGISTRY="docker.io"
# # Node version to use in base image, change with [--build-arg NODE_VERSION="22.14.0"]
# renovate: datasource=node-version depName=node
ARG NODE_VERSION="22.14.0"
ARG DISTRO_VERSION="3.21"
# Node image to use for base image based on combined variables (ex: 22.14.0-alpine3.21)
FROM ${BASE_REGISTRY}/node:${NODE_VERSION}-alpine${DISTRO_VERSION} AS node
# Resulting version string is vX.X.X-FIRES_VERSION_PRERELEASE+FIRES_VERSION_METADATA
# Example: v4.3.0-nightly.2023.11.09+pr-123456
# Overwrite existence of 'alpha.X' in version.json [--build-arg FIRES_VERSION_PRERELEASE="nightly.2023.11.09"]
ARG FIRES_VERSION_PRERELEASE=""
# Append build metadata or fork information to version.json [--build-arg FIRES_VERSION_METADATA="pr-123456"]
ARG FIRES_VERSION_METADATA=""
ARG SOURCE_COMMIT=""
# Timezone used by the Docker container and runtime, change with [--build-arg TZ=Europe/Berlin]
ARG TZ="Etc/UTC"
# Linux UID (user id) for the fires user, change with [--build-arg UID=1234]
ARG UID="991"
# Linux GID (group id) for the fires user, change with [--build-arg GID=1234]
ARG GID="991"
# Apply FIRES build options based on options above
ENV \
# Apply FIRES version information
FIRES_VERSION_PRERELEASE="${FIRES_VERSION_PRERELEASE}" \
FIRES_VERSION_METADATA="${FIRES_VERSION_METADATA}" \
SOURCE_COMMIT="${SOURCE_COMMIT}" \
# Apply timezone
TZ=${TZ}
ENV \
# Configure the IP to bind to when serving traffic
HOST="0.0.0.0" \
# Use production settings for nodejs based tools
NODE_ENV="production"
# Set default shell used for running commands
SHELL ["/bin/sh", "-o", "pipefail", "-o", "errexit", "-c"]
ARG TARGETPLATFORM
RUN echo "Target platform is $TARGETPLATFORM";
RUN \
# Sets timezone
echo "${TZ}" > /etc/localtime; \
# Creates fires user/group and sets home directory
addgroup -Sg "${GID}" fires; \
adduser -S -u "${UID}" -h /opt/fires fires fires;
# Set /opt/mastodon as working directory
WORKDIR /opt/fires
# hadolint ignore=DL3008,DL3005
RUN \
# Mount Apk cache directory from Docker buildx caches
--mount=type=cache,id=apk-cache-${TARGETPLATFORM},target=/var/cache/apk/,sharing=locked \
# Apk update & upgrade to check for security updates to Debian image
apk update; \
apk upgrade; \
# Install curl and tini
apk add \
tini=0.19.0-r3 \
tzdata=2025b-r0 \
curl=8.14.1-r2 \
jq=1.7.1-r0;
# Configure pnpm
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
# Create temporary build layer from base image
FROM node AS build
ARG TARGETPLATFORM
COPY . /opt/fires
WORKDIR /opt/fires
# Configure Corepack
RUN \
corepack enable; \
corepack prepare --activate;
# hadolint ignore=DL3059
RUN --mount=type=cache,id=pnpm-${TARGETPLATFORM},target=/pnpm/store pnpm install --filter !@fedimod/fires-docs --frozen-lockfile
# hadolint ignore=DL3059
RUN pnpm run --filter=@fedimod/fires-server -r build
# hadolint ignore=DL3059
RUN pnpm deploy --filter=@fedimod/fires-server --prod /fires-server-deploy
FROM node AS fires-server
COPY --from=build /opt/fires/components/fires-server/build /opt/fires-server/
COPY --from=build /fires-server-deploy/pnpm-lock.yaml /fires-server-deploy/package.json /opt/fires-server/
COPY --from=build /fires-server-deploy/node_modules /opt/fires-server/node_modules/
WORKDIR /opt/fires-server/
USER fires
EXPOSE 4444
# Set container tini as default entry point
ENTRYPOINT ["/sbin/tini", "--"]
LABEL org.opencontainers.image.description="FediMod FIRES Reference Server"
LABEL org.opencontainers.image.source=https://github.com/fedimod/fires
LABEL org.opencontainers.image.licenses=AGPL-3.0
CMD ["node", "bin/server.js"]