Skip to content

Commit 4b9d5a7

Browse files
authored
Merge pull request #1699 from AshCorr/ash/Containers!
Bundle CyberChef into a container and publish to GCHR
2 parents fc7c631 + 62dfa8f commit 4b9d5a7

File tree

5 files changed

+82
-5
lines changed

5 files changed

+82
-5
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
build

.github/workflows/pull_requests.yml

+14
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ jobs:
3333
if: success()
3434
run: npx grunt prod
3535

36+
- name: Production Image Build
37+
if: success()
38+
id: build-image
39+
uses: redhat-actions/buildah-build@v2
40+
with:
41+
# Not being uploaded to any registry, use a simple name to allow Buildah to build correctly.
42+
image: cyberchef
43+
containerfiles: ./Dockerfile
44+
platforms: linux/amd64
45+
oci: true
46+
# Webpack seems to use a lot of open files, increase the max open file limit to accomodate.
47+
extra-args: |
48+
--ulimit nofile=10000
49+
3650
- name: UI Tests
3751
if: success()
3852
run: |

.github/workflows/releases.yml

+41-5
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@ on:
66
tags:
77
- 'v*'
88

9+
env:
10+
REGISTRY: ghcr.io
11+
REGISTRY_USER: ${{ github.actor }}
12+
REGISTRY_PASSWORD: ${{ github.token }}
13+
IMAGE_NAME: ${{ github.repository }}
14+
915
jobs:
1016
main:
1117
runs-on: ubuntu-latest
18+
permissions:
19+
packages: write
1220
steps:
1321
- uses: actions/checkout@v3
1422

@@ -19,7 +27,7 @@ jobs:
1927

2028
- name: Install
2129
run: |
22-
npm install
30+
npm ci
2331
npm run setheapsize
2432
2533
- name: Lint
@@ -31,17 +39,38 @@ jobs:
3139
npm run testnodeconsumer
3240
3341
- name: Production Build
34-
if: success()
3542
run: npx grunt prod
3643

3744
- name: UI Tests
38-
if: success()
3945
run: |
4046
sudo apt-get install xvfb
4147
xvfb-run --server-args="-screen 0 1200x800x24" npx grunt testui
4248
49+
- name: Image Metadata
50+
id: image-metadata
51+
uses: docker/metadata-action@v4
52+
with:
53+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
54+
tags: |
55+
type=semver,pattern={{major}}
56+
type=semver,pattern={{major}}.{{minor}}
57+
type=semver,pattern={{version}}
58+
59+
- name: Production Image Build
60+
id: build-image
61+
uses: redhat-actions/buildah-build@v2
62+
with:
63+
tags: ${{ steps.image-metadata.outputs.tags }}
64+
labels: ${{ steps.image-metadata.outputs.labels }}
65+
containerfiles: ./Dockerfile
66+
platforms: linux/amd64
67+
oci: true
68+
# Webpack seems to use a lot of open files, increase the max open file limit to accomodate.
69+
extra-args: |
70+
--ulimit nofile=10000
71+
72+
4373
- name: Upload Release Assets
44-
if: success()
4574
id: upload-release-assets
4675
uses: svenstaro/upload-release-action@v2
4776
with:
@@ -53,7 +82,14 @@ jobs:
5382
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."
5483

5584
- name: Publish to NPM
56-
if: success()
5785
uses: JS-DevTools/npm-publish@v1
5886
with:
5987
token: ${{ secrets.NPM_TOKEN }}
88+
89+
- name: Publish to GHCR
90+
uses: redhat-actions/push-to-registry@v2
91+
with:
92+
tags: ${{ steps.build-image.outputs.tags }}
93+
registry: ${{ env.REGISTRY }}
94+
username: ${{ env.REGISTRY_USER }}
95+
password: ${{ env.REGISTRY_PASSWORD }}

Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM node:18-alpine AS build
2+
3+
COPY . .
4+
RUN npm ci
5+
RUN npm run build
6+
7+
FROM nginx:1.25-alpine3.18 AS cyberchef
8+
9+
COPY --from=build ./build/prod /usr/share/nginx/html/

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ Cryptographic operations in CyberChef should not be relied upon to provide secur
2020

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

23+
## Containers
24+
25+
If you would like to try out CyberChef locally you can either build it yourself:
26+
27+
```bash
28+
docker build --tag cyberchef --ulimit nofile=10000 .
29+
docker run -it -p 8080:80 cyberchef
30+
```
31+
32+
Or you can use our image directly:
33+
34+
```bash
35+
docker run -it -p 8080:80 ghcr.io/gchq/cyberchef:latest
36+
```
37+
38+
This image is built and published through our [GitHub Workflows](.github/workflows/releases.yml)
2339

2440
## How it works
2541

0 commit comments

Comments
 (0)