Skip to content

Commit

Permalink
feat(website): build website image for arm, use current astro docs re…
Browse files Browse the repository at this point in the history
…commended Dockerfile (#1827)
  • Loading branch information
corneliusroemer authored May 9, 2024
1 parent c29b912 commit 2f62946
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ name: website
on:
push:
workflow_dispatch:
inputs:
build_arm:
type: boolean
description: "Build for ARM as well"
default: false
required: false

env:
DOCKER_IMAGE_NAME: ghcr.io/loculus-project/website
BUILD_ARM: ${{ github.ref == 'refs/heads/main' || github.event.inputs.build_arm }} # When to build for arm as well

concurrency:
group: ci-${{ github.ref == 'refs/heads/main' && github.run_id || github.ref }}-website
Expand All @@ -27,7 +34,7 @@ jobs:
id: files-hash
run: |
DIR_HASH=$(echo -n ${{ hashFiles('website/**', '.github/workflows/website.yml') }})
echo "DIR_HASH=$DIR_HASH" >> $GITHUB_ENV
echo "DIR_HASH=$DIR_HASH${{ env.BUILD_ARM && '-arm'|| '' }}" >> $GITHUB_ENV
- name: Setup Docker metadata
id: dockerMetadata
Expand Down Expand Up @@ -65,6 +72,7 @@ jobs:
tags: ${{ steps.dockerMetadata.outputs.tags }}
cache-from: type=gha,scope=website-${{ github.ref }}
cache-to: type=gha,mode=max,scope=website-${{ github.ref }}
platforms: ${{ env.BUILD_ARM && 'linux/amd64,linux/arm64' || 'linux/amd64' }}

- name: Retag and push existing image if cache hit
if: env.CACHE_HIT == 'true'
Expand Down
28 changes: 14 additions & 14 deletions website/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
FROM node:lts-alpine as build-deps
FROM node:lts-alpine as base
WORKDIR /app

COPY .env.docker .env
COPY package*.json ./
COPY package.json package-lock.json ./

RUN npm ci
COPY . .
RUN npm run build

FROM node:lts-alpine
FROM base as prod-deps
RUN npm install --omit=dev

WORKDIR /app

COPY .env.docker .env
COPY package*.json ./
RUN npm ci --omit=dev
FROM base as build-deps
RUN npm install

COPY --from=build-deps /app/dist ./dist
FROM build-deps as build
COPY . .
RUN npm run build

CMD node ./dist/server/entry.mjs
FROM base AS runtime
COPY --from=prod-deps /app/node_modules ./node_modules
COPY --from=build /app/dist ./dist

EXPOSE 3000
VOLUME /config
VOLUME /log

CMD node ./dist/server/entry.mjs

0 comments on commit 2f62946

Please sign in to comment.