mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 23:36:16 -04:00
Merge pull request #1974 from PathToLife/feature/docker-multiplatform-build
Docker multiplatform build support
This commit is contained in:
commit
305a02c8a2
2 changed files with 45 additions and 14 deletions
22
.github/workflows/releases.yml
vendored
22
.github/workflows/releases.yml
vendored
|
@ -25,6 +25,7 @@ jobs:
|
|||
|
||||
- name: Install
|
||||
run: |
|
||||
export DETECT_CHROMEDRIVER_VERSION=true
|
||||
npm ci
|
||||
npm run setheapsize
|
||||
|
||||
|
@ -61,12 +62,22 @@ jobs:
|
|||
tags: ${{ steps.image-metadata.outputs.tags }}
|
||||
labels: ${{ steps.image-metadata.outputs.labels }}
|
||||
containerfiles: ./Dockerfile
|
||||
platforms: linux/amd64
|
||||
platforms: linux/amd64,linux/arm64
|
||||
oci: true
|
||||
# enable build layer caching between platforms
|
||||
layers: true
|
||||
# Webpack seems to use a lot of open files, increase the max open file limit to accomodate.
|
||||
extra-args: |
|
||||
--ulimit nofile=10000
|
||||
|
||||
- name: Publish to GHCR
|
||||
uses: redhat-actions/push-to-registry@v2
|
||||
with:
|
||||
image: ${{ steps.build-image.outputs.image }}
|
||||
tags: ${{ steps.build-image.outputs.tags }}
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ env.REGISTRY_USER }}
|
||||
password: ${{ env.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Upload Release Assets
|
||||
id: upload-release-assets
|
||||
|
@ -81,13 +92,6 @@ jobs:
|
|||
|
||||
- name: Publish to NPM
|
||||
uses: JS-DevTools/npm-publish@v1
|
||||
if: false
|
||||
with:
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
- name: Publish to GHCR
|
||||
uses: redhat-actions/push-to-registry@v2
|
||||
with:
|
||||
tags: ${{ steps.build-image.outputs.tags }}
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ env.REGISTRY_USER }}
|
||||
password: ${{ env.REGISTRY_PASSWORD }}
|
||||
|
|
35
Dockerfile
35
Dockerfile
|
@ -1,9 +1,36 @@
|
|||
FROM node:18-alpine AS build
|
||||
#####################################
|
||||
# Build the app to a static website #
|
||||
#####################################
|
||||
# Modifier --platform=$BUILDPLATFORM limits the platform to "BUILDPLATFORM" during buildx multi-platform builds
|
||||
# This is because npm "chromedriver" package is not compatiable with all platforms
|
||||
# For more info see: https://docs.docker.com/build/building/multi-platform/#cross-compilation
|
||||
FROM --platform=$BUILDPLATFORM node:18-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json .
|
||||
COPY package-lock.json .
|
||||
|
||||
# Install dependencies
|
||||
# --ignore-scripts prevents postinstall script (which runs grunt) as it depends on files other than package.json
|
||||
RUN npm ci --ignore-scripts
|
||||
|
||||
# Copy files needed for postinstall and build
|
||||
COPY . .
|
||||
RUN npm ci
|
||||
|
||||
# npm postinstall runs grunt, which depends on files other than package.json
|
||||
RUN npm run postinstall
|
||||
|
||||
# Build the app
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:1.25-alpine3.18 AS cyberchef
|
||||
#########################################
|
||||
# Package static build files into nginx #
|
||||
#########################################
|
||||
# We are using Github Actions: redhat-actions/buildah-build@v2 which needs manual selection of arch in base image
|
||||
# Remove TARGETARCH if docker buildx is supported in the CI release as --platform=$TARGETPLATFORM will be automatically set
|
||||
ARG TARGETARCH
|
||||
ARG TARGETPLATFORM
|
||||
FROM ${TARGETARCH}/nginx:stable-alpine AS cyberchef
|
||||
|
||||
COPY --from=build ./build/prod /usr/share/nginx/html/
|
||||
COPY --from=builder /app/build/prod /usr/share/nginx/html/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue