mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 15:26: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
|
- name: Install
|
||||||
run: |
|
run: |
|
||||||
|
export DETECT_CHROMEDRIVER_VERSION=true
|
||||||
npm ci
|
npm ci
|
||||||
npm run setheapsize
|
npm run setheapsize
|
||||||
|
|
||||||
|
@ -61,12 +62,22 @@ jobs:
|
||||||
tags: ${{ steps.image-metadata.outputs.tags }}
|
tags: ${{ steps.image-metadata.outputs.tags }}
|
||||||
labels: ${{ steps.image-metadata.outputs.labels }}
|
labels: ${{ steps.image-metadata.outputs.labels }}
|
||||||
containerfiles: ./Dockerfile
|
containerfiles: ./Dockerfile
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64,linux/arm64
|
||||||
oci: true
|
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.
|
# Webpack seems to use a lot of open files, increase the max open file limit to accomodate.
|
||||||
extra-args: |
|
extra-args: |
|
||||||
--ulimit nofile=10000
|
--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
|
- name: Upload Release Assets
|
||||||
id: upload-release-assets
|
id: upload-release-assets
|
||||||
|
@ -81,13 +92,6 @@ jobs:
|
||||||
|
|
||||||
- name: Publish to NPM
|
- name: Publish to NPM
|
||||||
uses: JS-DevTools/npm-publish@v1
|
uses: JS-DevTools/npm-publish@v1
|
||||||
|
if: false
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.NPM_TOKEN }}
|
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 . .
|
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
|
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