-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from cerberauth/create-docker-images
build: add dockerfile and push to ghcr
- Loading branch information
Showing
5 changed files
with
103 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
list-challenges: | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- id: set-matrix | ||
run: echo "matrix=$(ls challenges/ | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT | ||
|
||
docker-build-push: | ||
needs: list-challenges | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
packages: write | ||
|
||
strategy: | ||
matrix: | ||
challenge: ${{ fromJson(needs.list-challenges.outputs.matrix) }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./challenges/${{ matrix.challenge }} | ||
push: ${{ github.ref == 'refs/heads/main' }} | ||
tags: ghcr.io/cerberauth/api-vulns-challenges/${{ matrix.challenge }}:latest | ||
cache-from: type=registry,ref=ghcr.io/cerberauth/api-vulns-challenges/${{ matrix.challenge }}:latest | ||
cache-to: type=inline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM golang:1.21 AS builder | ||
|
||
WORKDIR /app | ||
|
||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
COPY . ./ | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -o /jwt-alg-none-bypass . | ||
|
||
FROM gcr.io/distroless/static-debian11:nonroot AS runner | ||
|
||
WORKDIR / | ||
|
||
COPY --from=builder --chown=nonroot:nonroot /jwt-alg-none-bypass /usr/bin/jwt-alg-none-bypass | ||
|
||
EXPOSE 8080 | ||
|
||
USER nonroot:nonroot | ||
|
||
ENTRYPOINT ["jwt-alg-none-bypass", "serve"] | ||
CMD ["jwt-alg-none-bypass"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM golang:1.21 AS builder | ||
|
||
WORKDIR /app | ||
|
||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
COPY . ./ | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -o /jwt-weak-hmac-secret . | ||
|
||
FROM gcr.io/distroless/static-debian11:nonroot AS runner | ||
|
||
WORKDIR / | ||
|
||
COPY --from=builder --chown=nonroot:nonroot /jwt-weak-hmac-secret /usr/bin/jwt-weak-hmac-secret | ||
|
||
EXPOSE 8080 | ||
|
||
USER nonroot:nonroot | ||
|
||
ENTRYPOINT ["jwt-weak-hmac-secret", "serve"] | ||
CMD ["jwt-weak-hmac-secret"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters