Skip to content

Commit

Permalink
Merge pull request #217 from JJ-8/0-pre-build-docker-images-through-ghcr
Browse files Browse the repository at this point in the history
Add pre-build Docker images through GHCR
  • Loading branch information
XeR authored Sep 24, 2023
2 parents e766b31 + 8efa9ba commit b58f2b7
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 2 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "Build and publish Docker images to GHCR"

on:
push:
branches:
- "main"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.job }}
cancel-in-progress: true

permissions:
contents: read
packages: write

jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
component: ["front", "api", "db"]
steps:
- name: PrepareReg Names
run: |
echo IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
echo IMAGE_TAG=$(echo ${{ github.ref }} | tr '[:upper:]' '[:lower:]' | awk '{split($0,a,"/"); print a[3]}') >> $GITHUB_ENV
echo IMAGE_REPOSITORY_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
- name: Generate Docker metadata for ${{ matrix.component }}
id: meta-data
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ env.IMAGE_REPOSITORY }}/${{ matrix.component }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=semver,pattern={{version}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
platforms: linux/amd64,linux/arm64
context: ./${{ matrix.component }}
tags: ${{ steps.meta-data.outputs.tags }}
labels: ${{ steps.meta-data.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.component }}
cache-to: type=gha,scope=${{ matrix.component }}
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,29 @@ CTFNote is a collaborative tool aiming to help CTF teams to organise their work.

Before starting, make sure to fill in the information in the `.env` file.

Then you can start it with `docker-compose`. The default
### Pre-build images

Building CTFNote requires at least 3 GB of RAM. If you want to host CTFNote
on a server with less than 3 GB of RAM, you can use the pre-build images
from the GitHub Container Registry.

Download `docker-compose.yml` and `docker-compose.prebuild.yml` for example through cloning the repository and run:

```shell
$ docker compose -f docker-compose.prebuild.yml up -d --pull always
```

### Self-build images

You can build and start CTFNote with `docker compose`. The default
configuration makes it super easy to start a new instance!

```shell
$ docker-compose up -d
$ docker compose up -d
```

### Accessing the instance

The instance will spawn a web server on port `127.0.0.1:8080`. The first account created will
have administrative privileges.

Expand Down
30 changes: 30 additions & 0 deletions docker-compose.prebuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: "3.7"
services:
api:
image: ghcr.io/tfns/ctfnote/api:latest
extends:
file: docker-compose.yml
service: api
db:
image: ghcr.io/tfns/ctfnote/db:latest
extends:
file: docker-compose.yml
service: db
front:
image: ghcr.io/tfns/ctfnote/front:latest
extends:
file: docker-compose.yml
service: front
hedgedoc:
extends:
file: docker-compose.yml
service: hedgedoc
volumes:
ctfnote-db:
name: ctfnote
ctfnote-uploads:
name: ctfnote-uploads
pad-uploads:
name: pad-uploads
networks:
ctfnote:
1 change: 1 addition & 0 deletions front/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM node@sha256:1a9a71ea86aad332aa7740316d4111ee1bd4e890df47d3b5eff3e5bded3b3d10 AS build-deps

RUN apk add --no-cache python3 make g++
RUN mkdir -p /usr/src/app
COPY package.json quasar.conf.js .eslintrc.js .eslintignore tsconfig.json .postcssrc.js yarn.lock babel.config.js quasar.extensions.json /usr/src/app/
RUN cd /usr/src/app && yarn install
Expand Down

0 comments on commit b58f2b7

Please sign in to comment.