diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml new file mode 100644 index 000000000..c16b3c015 --- /dev/null +++ b/.github/workflows/build-and-publish.yml @@ -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 }} diff --git a/README.md b/README.md index 06269ca2e..9cde4b82d 100755 --- a/README.md +++ b/README.md @@ -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. diff --git a/docker-compose.prebuild.yml b/docker-compose.prebuild.yml new file mode 100644 index 000000000..1d4420216 --- /dev/null +++ b/docker-compose.prebuild.yml @@ -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: diff --git a/front/Dockerfile b/front/Dockerfile index 4c35f7329..bec77bf9c 100644 --- a/front/Dockerfile +++ b/front/Dockerfile @@ -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