Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle CyberChef into a container and publish to GCHR #1699

Merged
merged 16 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
build
14 changes: 14 additions & 0 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ jobs:
if: success()
run: npx grunt prod

- name: Production Image Build
if: success()
AshCorr marked this conversation as resolved.
Show resolved Hide resolved

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still required?

id: build-image
uses: redhat-actions/buildah-build@v2
with:
# Not being uploaded to any registry, use a simple name to allow Buildah to build correctly.
image: cyberchef
containerfiles: ./Dockerfile
platforms: linux/amd64
oci: true
# Webpack seems to use a lot of open files, increase the max open file limit to accomodate.
extra-args: |
--ulimit nofile=10000

- name: UI Tests
if: success()
run: |
Expand Down
46 changes: 41 additions & 5 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ on:
tags:
- 'v*'

env:
REGISTRY: ghcr.io
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ github.token }}
IMAGE_NAME: ${{ github.repository }}

jobs:
main:
AshCorr marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/checkout@v3

Expand All @@ -19,7 +27,7 @@ jobs:

- name: Install
run: |
npm install
npm ci
AshCorr marked this conversation as resolved.
Show resolved Hide resolved
npm run setheapsize

- name: Lint
Expand All @@ -31,17 +39,38 @@ jobs:
npm run testnodeconsumer

- name: Production Build
if: success()
run: npx grunt prod

- name: UI Tests
if: success()
run: |
sudo apt-get install xvfb
xvfb-run --server-args="-screen 0 1200x800x24" npx grunt testui

- name: Image Metadata
id: image-metadata
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{major}}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for the omission of:

                      type=raw,value=latest

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its added automatically when using a type=semver pattern! See https://github.com/docker/metadata-action?tab=readme-ov-file#latest-tag

type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{version}}

- name: Production Image Build
id: build-image
uses: redhat-actions/buildah-build@v2
with:
tags: ${{ steps.image-metadata.outputs.tags }}
labels: ${{ steps.image-metadata.outputs.labels }}
containerfiles: ./Dockerfile
platforms: linux/amd64
oci: true
# Webpack seems to use a lot of open files, increase the max open file limit to accomodate.
extra-args: |
--ulimit nofile=10000


- name: Upload Release Assets
if: success()
id: upload-release-assets
uses: svenstaro/upload-release-action@v2
with:
Expand All @@ -53,7 +82,14 @@ jobs:
body: "See the [CHANGELOG](https://github.com/gchq/CyberChef/blob/master/CHANGELOG.md) and [commit messages](https://github.com/gchq/CyberChef/commits/master) for details."

- name: Publish to NPM
if: success()
uses: JS-DevTools/npm-publish@v1
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 }}
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:18-alpine AS build

COPY . .
RUN npm ci
RUN npm run build

FROM nginx:1.25-alpine3.18 AS cyberchef

COPY --from=build ./build/prod /usr/share/nginx/html/
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ Cryptographic operations in CyberChef should not be relied upon to provide secur

[A live demo can be found here][1] - have fun!

## Containers

If you would like to try out CyberChef locally you can either build it yourself:

```bash
docker build --tag cyberchef --ulimit nofile=10000 .
docker run -it -p 8080:80 cyberchef
```

Or you can use our image directly:

```bash
docker run -it -p 8080:80 ghcr.io/gchq/cyberchef:latest
```

This image is built and published through our [GitHub Workflows](.github/workflows/releases.yml)

## How it works

Expand Down
Loading