diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fe8d466..95feb5f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,20 +10,12 @@ jobs: build_and_test: name: Build and test runs-on: ubuntu-latest - env: - GOPATH: ${{ github.workspace }} - defaults: - run: - working-directory: ${{ env.GOPATH }}/src/github.com/${{ github.repository }} steps: - uses: actions/checkout@v3 - with: - path: ${{ env.GOPATH }}/src/github.com/${{ github.repository }} - - name: Set up Go uses: actions/setup-go@v4 with: - go-version: 1.20.x + go-version: 1.21.x - name: Install dependencies run: go mod download @@ -36,7 +28,7 @@ jobs: build_docker: if: startsWith(github.event.ref, 'refs/tags/v') - name: Build and publish docker image + name: Build and publish docker images needs: build_and_test runs-on: ubuntu-latest permissions: @@ -59,13 +51,20 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - ${{ github.ref_name }} - latest + type=semver,pattern=v{{version}} + type=semver,pattern=v{{major}}.{{minor}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Build and push Docker image uses: docker/build-push-action@v5 with: - context: . push: true + provenance: false tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 diff --git a/Dockerfile b/Dockerfile index f26985f..705fdab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,7 @@ -FROM golang:1.20-alpine AS build +FROM --platform=$BUILDPLATFORM golang:1.20-alpine AS build + +ARG TARGETOS +ARG TARGETARCH WORKDIR /app @@ -6,7 +9,7 @@ COPY go.mod go.sum ./ RUN go mod download COPY . . -RUN go build +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build FROM alpine:3.18 diff --git a/README.md b/README.md index cf8f9be..9115f7c 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ It also requires you to specify a list of known-users, simplifying it greatly as ### Usage First, create a [.env](.env.example) and specify the initial usernames and passwords for access. +Make sure to fill out `GENESIS_JWT_SECRET` with a secure, random string, for that you can use `openssl rand -hex 32`. You can specify the remaining values, but the defaults are good for medium-sized projects such as [ocular](https://github.com/Simonwep/ocular). Second, start the server via `go run .`. That's it. @@ -34,15 +35,13 @@ The `json` is pre-processed by the [minify](https://github.com/tdewolff/minify) #### Using docker -This API can also be deployed by using docker. -For this you can build and run the container using the following command: +You can run genesis using [docker](https://www.docker.com/products/docker-desktop/) by using pre-build images: ```sh -docker build -t genesis . -docker run -p 8088:8080 -v "$(pwd)/.data:/app/.data" --env-file .env genesis +docker run -p 8080:8080 -v "$(pwd)/.data:/app/.data" --env-file .env ghcr.io/simonwep/genesis:latest ``` -Genesis should then be accessible under port `8088`. +Genesis should then be accessible under port `8080`. ### API