Skip to content

Commit

Permalink
Build and push Docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
justim committed Jul 27, 2022
1 parent cb00fdd commit 337a1d7
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
68 changes: 68 additions & 0 deletions .github/workflows/docker-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Docker

on:
push:
branches:
- master
tags:
- v*.*.*
pull_request:
branches:
- master

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
Docker:
name: Build & push

strategy:
fail-fast: true
matrix:
features:
- memory
- postgres

runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
suffix=-${{ matrix.features }},type=ref,event=branch
suffix=-${{ matrix.features }},type=semver,pattern={{version}}
suffix=-${{ matrix.features }},type=semver,pattern={{major}}.{{minor}}
suffix=-${{ matrix.features }},type=ref,event=pr
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
build-args: |
SHURLY_FEATURES=${{ matrix.features }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ An extra requirement is needed to actually run Shurly with a database, that is
an actual database. This can be setup separately, or the [Docker Compose] setup
can be used, which will run a PostgreSQL server container.

A simple `docker compose up` will get you started. Use `docker compose up --build` to rebuild the Shurly image.
A simple `docker compose up` will get you started. Use `docker compose up
--build` to rebuild the Shurly image.

> The Docker Compose setup also runs the Docker version of Shurly, this might
> not be ideal for fast development iterations. Docker Compose provides the
Expand All @@ -169,6 +170,16 @@ A simple `docker compose up` will get you started. Use `docker compose up --buil
When running it without Docker, there needs to be a `DATABASE_URL` environment
variable.
## Pre-built Docker images
For those who like to use Docker, but don't want to go through the hassle of
building the images; pre-built images are available:
- With `memory` feature: [`ghcr.io/workplacebuddy/shurly:master-memory`]
- With `postgres` feature: [`ghcr.io/workplacebuddy/shurly:master-postgres`]
- More information and tags available here:
https://github.com/workplacebuddy/shurly/pkgs/container/shurly
## Configuration
When running with the defaults, missing configuration has a sane default oris
Expand Down Expand Up @@ -268,3 +279,5 @@ Using the `SQLx` CLI adds a couple of nicities to work with migrations.
[docker compose]: https://docs.docker.com/compose/
[`tracing`]: https://lib.rs/crates/tracing
[other options]: https://github.com/launchbadge/sqlx/blob/main/sqlx-cli/README.md
[`ghcr.io/workplacebuddy/shurly:master-memory`]: https://github.com/workplacebuddy/shurly/pkgs/container/shurly
[`ghcr.io/workplacebuddy/shurly:master-postgres`]: https://github.com/workplacebuddy/shurly/pkgs/container/shurly

0 comments on commit 337a1d7

Please sign in to comment.