Skip to content

Commit a78603d

Browse files
committed
Convert to Debian and improve credentials
- Convert the image to use a Debian base image. - Rework how credentials are passed into the build using new mounted secrets.
1 parent ba135a5 commit a78603d

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

Dockerfile

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
ARG FOUNDRY_PASSWORD
21
ARG FOUNDRY_RELEASE_URL
3-
ARG FOUNDRY_USERNAME
42
ARG FOUNDRY_VERSION=13.332
5-
ARG NODE_IMAGE_VERSION=18-alpine3.18
3+
ARG NODE_IMAGE_VERSION=20-bookworm-slim
64
ARG VERSION
75

86
FROM node:${NODE_IMAGE_VERSION} AS compile-typescript-stage
@@ -22,7 +20,6 @@ RUN grep -l "#!" dist/*.js | xargs chmod a+x
2220
FROM node:${NODE_IMAGE_VERSION} AS optional-release-stage
2321

2422
ARG FOUNDRY_RELEASE_URL
25-
ARG FOUNDRY_USERNAME
2623
ARG FOUNDRY_VERSION
2724
ENV ARCHIVE="foundryvtt-${FOUNDRY_VERSION}.zip"
2825

@@ -36,15 +33,28 @@ COPY --from=compile-typescript-stage \
3633
./
3734
# .placeholder file to mitigate https://github.com/moby/moby/issues/37965
3835
RUN mkdir dist && touch dist/.placeholder
39-
RUN \
36+
RUN --mount=type=secret,id=foundry_credentials,required=false \
37+
npm install classic-level && \
38+
if [ -f /run/secrets/foundry_credentials ]; then \
39+
# Extract credentials from JSON
40+
apt-get update && apt-get install -y jq && \
41+
FOUNDRY_USERNAME=$(jq -r '.foundry_username // empty' /run/secrets/foundry_credentials) && \
42+
FOUNDRY_PASSWORD=$(jq -r '.foundry_password // empty' /run/secrets/foundry_credentials); \
43+
fi && \
4044
if [ -n "${FOUNDRY_USERNAME}" ] && [ -n "${FOUNDRY_PASSWORD}" ]; then \
41-
npm install && \
45+
# Authenticate using credentials and get the pre-signed URL
4246
./authenticate.js "${FOUNDRY_USERNAME}" "${FOUNDRY_PASSWORD}" cookiejar.json && \
4347
presigned_url=$(./get_release_url.js --retry 5 cookiejar.json "${FOUNDRY_VERSION}") && \
44-
wget -O ${ARCHIVE} "${presigned_url}" && \
45-
unzip -d dist ${ARCHIVE} 'resources/*'; \
48+
DOWNLOAD_URL="${presigned_url}"; \
4649
elif [ -n "${FOUNDRY_RELEASE_URL}" ]; then \
47-
wget -O ${ARCHIVE} "${FOUNDRY_RELEASE_URL}" && \
50+
# Use pre-signed URL
51+
DOWNLOAD_URL="${FOUNDRY_RELEASE_URL}"; \
52+
else \
53+
echo "No valid credentials or pre-signed URL provided. Skipping pre-installation."; \
54+
fi && \
55+
if [ -n "${DOWNLOAD_URL}" ]; then \
56+
apt-get install -y unzip wget && \
57+
wget -O ${ARCHIVE} "${DOWNLOAD_URL}" && \
4858
unzip -d dist ${ARCHIVE} 'resources/*'; \
4959
fi
5060

@@ -76,13 +86,15 @@ COPY \
7686
./
7787
RUN addgroup --system --gid ${FOUNDRY_UID} foundry \
7888
&& adduser --system --uid ${FOUNDRY_UID} --ingroup foundry foundry \
79-
&& apk --update --no-cache add \
89+
&& apt-get update && apt-get install -y \
8090
curl \
8191
file \
92+
gosu \
8293
jq \
8394
sed \
84-
su-exec \
8595
tzdata \
96+
unzip \
97+
&& rm -rf /var/lib/apt/lists/* \
8698
&& npm install && echo ${VERSION} > image_version.txt
8799

88100
VOLUME ["/data"]

0 commit comments

Comments
 (0)