Skip to content

Commit

Permalink
Test a build without alpine edge
Browse files Browse the repository at this point in the history
  • Loading branch information
ubergeek77 committed Dec 18, 2023
1 parent 1e7d750 commit db51be6
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 10 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build-multiarch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
file: ./${{ env.FE_REPO }}/Dockerfile
platforms: ${{ matrix.docker-target }}
push: true
tags: ${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.FE_REPO }}:${{ env.FE_TAG }}-${{ matrix.target-short }}
tags: testing-${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.FE_REPO }}:${{ env.FE_TAG }}-${{ matrix.target-short }}
- name: Build and push Backend (${{ env.BE_TAG }}, ${{ matrix.docker-target }})
if: github.event.inputs.be-tag != ''
uses: docker/build-push-action@v4
Expand All @@ -131,7 +131,7 @@ jobs:
file: ./${{ env.BE_REPO }}/Dockerfile
platforms: ${{ matrix.docker-target }}
push: true
tags: ${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.BE_REPO }}:${{ env.BE_TAG }}-${{ matrix.target-short }}
tags: testing-${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.BE_REPO }}:${{ env.BE_TAG }}-${{ matrix.target-short }}

stop-runners:
needs: [launch-runners,build-images]
Expand Down Expand Up @@ -175,16 +175,16 @@ jobs:
uses: ubergeek77/squash-docker-tags@v1
with:
source-tags: |
${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.FE_REPO }}:${{ env.FE_TAG }}-amd64
${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.FE_REPO }}:${{ env.FE_TAG }}-arm
${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.FE_REPO }}:${{ env.FE_TAG }}-arm64
destination-tag: ${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.FE_REPO }}:${{ env.FE_TAG }}
testing-${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.FE_REPO }}:${{ env.FE_TAG }}-amd64
testing-${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.FE_REPO }}:${{ env.FE_TAG }}-arm
testing-${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.FE_REPO }}:${{ env.FE_TAG }}-arm64
destination-tag: testing-${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.FE_REPO }}:${{ env.FE_TAG }}
- name: Squash Backend Multiarch Tags
if: github.event.inputs.be-tag != ''
uses: ubergeek77/squash-docker-tags@v1
with:
source-tags: |
${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.BE_REPO }}:${{ env.BE_TAG }}-amd64
${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.BE_REPO }}:${{ env.BE_TAG }}-arm
${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.BE_REPO }}:${{ env.BE_TAG }}-arm64
destination-tag: ${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.BE_REPO }}:${{ env.BE_TAG }}
testing-${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.BE_REPO }}:${{ env.BE_TAG }}-amd64
testing-${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.BE_REPO }}:${{ env.BE_TAG }}-arm
testing-${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.BE_REPO }}:${{ env.BE_TAG }}-arm64
destination-tag: testing-${{ env.DST_REGISTRY }}/${{ github.repository_owner }}/${{ env.BE_REPO }}:${{ env.BE_TAG }}
64 changes: 64 additions & 0 deletions Dockerfile-frontend
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
FROM node:20-alpine as builder

# 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 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

WORKDIR /usr/src/app

ENV npm_config_target_platform=linux
ENV npm_config_target_libc=musl

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

RUN yarn --production --prefer-offline --pure-lockfile --network-timeout 100000

# Build
COPY generate_translations.js \
tsconfig.json \
webpack.config.js \
.babelrc \
./

COPY lemmy-translations lemmy-translations
COPY src src
COPY .git .git

# Set UI version
RUN echo "export const VERSION = '$(git describe --tag)';" > "src/shared/version.ts"

RUN yarn --production --prefer-offline --network-timeout 100000
RUN NODE_OPTIONS="--max-old-space-size=8192" yarn build:prod

RUN rm -rf ./node_modules/import-sort-parser-typescript
RUN rm -rf ./node_modules/typescript
RUN rm -rf ./node_modules/npm

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

FROM node:20-alpine as runner
ENV NODE_ENV=production

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

RUN apk update && apk upgrade && apk add curl vips-cpp

COPY --from=builder /usr/src/app/dist /app/dist
COPY --from=builder /usr/src/app/node_modules /app/node_modules

RUN chown -R node:node /app

HEALTHCHECK --interval=60s --start-period=10s --retries=2 --timeout=10s CMD curl -ILfSs http://localhost:1234/ > /dev/null || exit 1

USER node
EXPOSE 1234
WORKDIR /app
CMD exec node dist/js/server.js

0 comments on commit db51be6

Please sign in to comment.