Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build docker image
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/release-automated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ needs.release.outputs.current_tag }}
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log into Docker Hub
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/release-manual-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log into Docker Hub
Expand Down
33 changes: 27 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
############################################################
# Build stage
############################################################
FROM node:20.19.0-alpine3.20 AS build
# Runs on the platform of the build machine, also when building the image for
# another platform, so that no code runs under emulation; Node.js running under
# QEMU emulation can crash with an illegal instruction. Builders that don't set
# BUILDPLATFORM, like the legacy Docker builder, run it on their own platform.
FROM --platform=${BUILDPLATFORM:-linux} node:20.19.0-alpine3.20 AS build

RUN apk --no-cache add \
build-base \
Expand All @@ -16,23 +20,40 @@ COPY package*.json ./
# Copy src to have config files for install
COPY . .

# Increase npm network timeout and retries for slow platforms (e.g. arm64 via QEMU)
# Increase npm network timeout and retries to tolerate network errors
ENV npm_config_fetch_retries=5
ENV npm_config_fetch_retry_mintimeout=60000
ENV npm_config_fetch_retry_maxtimeout=300000

# Install without scripts
RUN npm ci --omit=dev --ignore-scripts \
# Architecture of the image to build, set by BuildKit; builders that don't set
# it build the image for their own platform
ARG TARGETARCH

# Install production dependencies for the image platform without scripts
RUN arch="${TARGETARCH:-$(uname -m)}" \
&& case "$arch" in \
amd64|x86_64) cpu=x64 ;; \
arm64|aarch64) cpu=arm64 ;; \
arm|armv6l|armv7l) cpu=arm ;; \
ppc64le) cpu=ppc64 ;; \
s390x) cpu=s390x ;; \
*) echo "Unsupported target architecture: '$arch'" >&2; exit 1 ;; \
esac \
&& npm ci --omit=dev --ignore-scripts --os=linux --cpu="$cpu" --libc=musl \
# Copy production node_modules aside for later
&& cp -R node_modules prod_node_modules \
# Install all dependencies
&& npm ci \
# Run build steps
&& npm run build
&& npm run build \
# Create empty logs folder for the release stage
&& mkdir /logs

############################################################
# Release stage
############################################################
# Must not contain RUN instructions, because building the image for another
# platform than the one of the build machine would then require emulation.
FROM node:20.19.0-alpine3.20 AS release

VOLUME /parse-server/cloud /parse-server/config
Expand All @@ -47,7 +68,7 @@ COPY package*.json ./
COPY bin bin
COPY public public
COPY views views
RUN mkdir -p logs && chown -R node: logs
COPY --from=build --chown=node:node /logs logs

ENV PORT=1337
USER node
Expand Down
Loading