1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-18 20:59:39 +02:00

Self Hosting: Docker Compose setup and flow (#640)

* feat(self-hosting): add docker-compose and ghcr release workflow

* WIP: address review comments

* WIP: fix linting
This commit is contained in:
Radu C. Martin 2024-05-07 00:52:14 +02:00 committed by GitHub
parent 0616d3e2b7
commit 930dc26828
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 237 additions and 6 deletions

107
.github/workflows/publish.yml vendored Normal file
View file

@ -0,0 +1,107 @@
name: Publish Docker image
on:
push:
tags:
- 'v*'
branches:
- main
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
permissions:
contents: read
jobs:
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 10
services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Install packages
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libvips postgresql-client libpq-dev
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true
- name: Run tests and smoke test seed
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:postgres@localhost:5432
run: |
bin/rails db:create
bin/rails db:schema:load
bin/rails test:all
bin/rails db:seed
- name: Keep screenshots from failed system tests
uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshots
path: ${{ github.workspace }}/tmp/screenshots
if-no-files-found: ignore
build:
name: Build docker image
runs-on: ubuntu-latest
needs: [test]
permissions:
packages: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Docker Context for Buildx
run: docker context create builders
shell: bash
- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: latest=auto
tags: |
# Explicit commit sha and version tags
type=sha
type=semver,pattern={{version}}
# Aliases
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=stable,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
id: build
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}