Skip to content

Commit

Permalink
docker compose and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
bloodcloak committed Mar 27, 2024
1 parent 930d6c9 commit 8a74ff0
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build
on: [push]

jobs:
build:
name: Docker Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Prepare
id: prepare
run: |
IMAGE_NAME=yatb
GIT_REPO='https://github.com/${{ github.repository }}'
DOCKER_USER=`echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]'`
DOCKER_IMAGE=ghcr.io/$DOCKER_USER/$IMAGE_NAME
VERSION=`git rev-parse --short HEAD`
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
echo ::set-output name=git_repo::${GIT_REPO}
echo ::set-output name=docker_user::${DOCKER_USER}
echo ::set-output name=docker_image::${DOCKER_IMAGE}
echo ::set-output name=version::${VERSION}
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ steps.prepare.outputs.docker_user }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ (github.ref == 'refs/heads/master') || (contains(github.ref, 'refs/tags/') == true) }}
tags: |
${{ steps.prepare.outputs.docker_image }}:latest
${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
build-args: |
GIT_VERSION=${{ steps.prepare.outputs.version }}
GIT_REPO=${{ steps.prepare.outputs.git_repo }}
cache-from: type=gha
cache-to: type=gha,mode=max
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '3.6'
services:
db:
image: postgres:14
restart: unless-stopped
networks:
- internal
environment:
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASS}
volumes:
- ./db:/var/lib/postgresql/data:rw

bot:
image: ghcr.io/bsmg/yatb
restart: unless-stopped
depends_on:
- db
networks:
- internal
env_file:
- .env

networks:
internal:

0 comments on commit 8a74ff0

Please sign in to comment.