Skip to content

Commit

Permalink
chore: pre-build images for amd64 and arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwep committed Nov 2, 2023
1 parent c1263cd commit 51660b9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
27 changes: 13 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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 }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
FROM golang:1.20-alpine AS build
FROM --platform=$BUILDPLATFORM golang:1.20-alpine AS build

ARG TARGETOS
ARG TARGETARCH

WORKDIR /app

COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN go build
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build

FROM alpine:3.18

Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand Down

0 comments on commit 51660b9

Please sign in to comment.