Skip to content

Commit

Permalink
Use alpine edge, force upgrade sharp
Browse files Browse the repository at this point in the history
  • Loading branch information
ubergeek77 authored Oct 7, 2023
1 parent 0debe8a commit e4d53f0
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions Dockerfile-frontend
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ RUN cd /app && \
CGO_ENABLED=0 go build

# Original Dockerfile below (mostly)
FROM node:alpine3.17 as builder
FROM node:alpine as builder

# Upgrade to edge to fix sharp/libvips issues
RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/main" > /etc/apk/repositories && \
echo "https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories

# Added vips-dev and pkgconfig so that local vips is used instead of prebuilt
# Done for two reasons:
# - libvips binaries are not available for ARM32
# - It can break depending on the CPU (https://github.com/LemmyNet/lemmy-ui/issues/1566)
RUN apk update && apk add --no-cache curl yarn python3 build-base gcc wget git vips-dev pkgconfig
RUN apk update && apk upgrade && apk add --no-cache curl yarn python3 build-base gcc wget git vips-dev pkgconfig

# Install node-gyp
RUN npm install -g node-gyp
Expand All @@ -27,6 +31,9 @@ ENV npm_config_target_libc=musl

# Cache deps
COPY package.json yarn.lock ./

RUN sed -i 's|"sharp": "^0.32.4"|"sharp": "^0.32.6"|g' package.json

RUN yarn --production --prefer-offline --pure-lockfile

# Build
Expand Down Expand Up @@ -59,8 +66,13 @@ RUN rm -rf ./node_modules/npm

RUN du -sh ./node_modules/* | sort -nr | grep '\dM.*'

FROM node:alpine3.17 as runner
RUN apk add vips-cpp
FROM node:alpine as runner

# Upgrade to edge to fix sharp/libvips issues
RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/main" > /etc/apk/repositories && \
echo "https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories

RUN apk update && apk upgrade && apk add vips-cpp
COPY --from=builder /usr/src/app/dist /app/dist
COPY --from=builder /usr/src/app/node_modules /app/node_modules

Expand Down

0 comments on commit e4d53f0

Please sign in to comment.