chore: add docker build workflow

This commit is contained in:
moonrailgun 2023-10-21 20:19:27 +08:00
parent f6bb213c78
commit 4f58c7f5eb
2 changed files with 36 additions and 6 deletions

33
.github/workflows/docker-publish.yml vendored Normal file
View File

@ -0,0 +1,33 @@
name: "Docker Publish"
on:
workflow_dispatch:
push:
tags:
- 'v*.*.*'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: moonrailgun/tianji
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@ -1,18 +1,15 @@
version: '3' version: '3'
services: services:
tianji: tianji:
image: tianji image: moonrailgun/tianji
build:
context: .
ports: ports:
- "12345:12345" - "12345:12345"
environment: environment:
DATABASE_URL: postgresql://tianji:tianji@db:5432/tianji DATABASE_URL: postgresql://tianji:tianji@db:5432/tianji
JWT_SECRET: replace-me-with-a-random-string JWT_SECRET: replace-me-with-a-random-string
ALLOW_REGISTER: false ALLOW_REGISTER: "false"
depends_on: depends_on:
db: - postgres
condition: service_healthy
restart: always restart: always
postgres: postgres:
image: postgres:15.4-alpine image: postgres:15.4-alpine