Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Alpine 3.18 #1575

Merged
merged 1 commit into from
Jun 14, 2023
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
51 changes: 19 additions & 32 deletions diagrams.net/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,44 +1,31 @@
# Package the Node.js project into a single binary
FROM --platform=$BUILDPLATFORM node:16.18.1-alpine3.16 as builder
FROM node:18.16-alpine3.18

# Workaround: https://github.com/nodejs/docker-node/issues/813#issuecomment-407339011
# Error: could not get uid/gid
# [ 'nobody', 0 ]
RUN npm config set unsafe-perm true
RUN addgroup -g 1001 kroki && adduser -D -G kroki -u 1001 kroki

RUN npm install -g pkg@5.6.0 pkg-fetch@3.3.0
RUN apk add --quiet --no-cache --update \
chromium \
font-noto-cjk

ARG TARGETARCH
ENV NODE node16
ENV PLATFORM alpine
RUN /usr/local/bin/pkg-fetch -n $NODE -p $PLATFORM -a $([ "$TARGETARCH" = "amd64" ] && echo "x64" || echo "$TARGETARCH")

COPY package.json package-lock.json /app/
COPY src /app/src
WORKDIR /app

RUN PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 npm ci --target_arch=$([ "$TARGETARCH" = "amd64" ] && echo "x64" || echo "$TARGETARCH") --target_platform=$PLATFORM
RUN npm run lint

RUN /usr/local/bin/pkg --targets $NODE-$PLATFORM-$([ "$TARGETARCH" = "amd64" ] && echo "x64" || echo "$TARGETARCH") . -o app.bin

# Create the image
FROM alpine:3.16.3

RUN addgroup -g 1000 kroki && adduser -D -G kroki -u 1000 kroki

RUN apk add --quiet --no-cache --update chromium
USER kroki
WORKDIR /usr/local/kroki/

COPY --from=builder /app/app.bin /usr/bin/diagramsnet
COPY --chown=kroki:kroki assets /usr/local/kroki/assets
RUN mkdir -p /usr/local/kroki/node && chown kroki:kroki -R /usr/local/kroki

ENV KROKI_DIAGRAMSNET_PAGE_URL=file:///usr/local/kroki/assets/index.html
ENV KROKI_EXCALIDRAW_PAGE_URL=file:///usr/local/kroki/assets/index.html
# 15 seconds
ENV KROKI_DIAGRAMSNET_CONVERT_TIMEOUT=15000
ENV PUPPETEER_EXECUTABLE_PATH=/usr/lib/chromium/chrome
#ENV DEBUG="puppeteer:*"
ENV LEVEL="info"

COPY --chown=kroki:kroki src ./src
COPY --chown=kroki:kroki package*.json ./
COPY --chown=kroki:kroki assets ./assets

RUN npm i --omit=dev

EXPOSE 8005

USER kroki
ENTRYPOINT ["node", "src/index.js"]


ENTRYPOINT ["/usr/bin/diagramsnet"]
Loading