add GitHub actions workflows and build docker image (#9)
* add default values for CLI args * add development docker compose file * prevent crash if userdata dir does not exist * accounts, acccountStats * account stats and create db indices * compensations and daily runs * ensure uniqueness of daily seed * start on port 8001 by default for client parity * add GitHub actions scripts and dockerfile * add os architecture * only build docker image on main repo * add example compose filebetter-accounts
parent
b5e8094039
commit
a8502fcd3f
|
@ -0,0 +1,10 @@
|
|||
/.github/
|
||||
|
||||
Dockerfile*
|
||||
docker-compose*.yml
|
||||
|
||||
/.data/
|
||||
/secret.key
|
||||
|
||||
/rogueserver*
|
||||
!/rogueserver.go
|
|
@ -0,0 +1,46 @@
|
|||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build (${{ matrix.os_name }})
|
||||
env:
|
||||
GO_VERSION: 1.22
|
||||
GOOS: ${{ matrix.os_name }}
|
||||
GOARCH: ${{ matrix.arch }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
os_name: linux
|
||||
arch: amd64
|
||||
- os: windows-latest
|
||||
os_name: windows
|
||||
arch: amd64
|
||||
# TODO macos needs universal binary!
|
||||
# - os: macos-latest
|
||||
# os_name: macos
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Go ${{ env.GO_VERSION }}
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
- name: Install dependencies
|
||||
run: go mod download
|
||||
- name: Test
|
||||
run: go test -v
|
||||
- name: Build
|
||||
run: go build -v
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: rogueserver-${{ matrix.os_name }}-${{ matrix.arch }}-${{ github.sha }}
|
||||
path: |
|
||||
rogueserver*
|
||||
!rogueserver.go
|
|
@ -0,0 +1,38 @@
|
|||
name: Publish to GHCR
|
||||
|
||||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build and publish to GHCR
|
||||
if: github.repository == 'pagefaultgames/rogueserver'
|
||||
env:
|
||||
GO_VERSION: 1.22
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup Docker BuildX
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Log into container registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ github.token }}
|
||||
- name: Extract Docker metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ghcr.io/${{ github.repository }}
|
||||
- name: Build Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
build-args: |
|
||||
GO_VERSION=${{ env.GO_VERSION }}
|
||||
VERSION=${{ github.ref_name }}-SNAPSHOT
|
||||
COMMIT_SHA=${{ env.GITHUB_SHA_SHORT }}
|
|
@ -0,0 +1,29 @@
|
|||
ARG GO_VERSION=1.22
|
||||
|
||||
FROM golang:${GO_VERSION} AS builder
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
COPY ./go.mod /src/
|
||||
COPY ./go.sum /src/
|
||||
|
||||
RUN go mod download && go mod verify
|
||||
|
||||
COPY . /src/
|
||||
|
||||
RUN CGO_ENABLED=0 \
|
||||
go build -o rogueserver
|
||||
|
||||
RUN chmod +x /src/rogueserver
|
||||
|
||||
# ---------------------------------------------
|
||||
|
||||
FROM scratch
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /src/rogueserver .
|
||||
|
||||
EXPOSE 8001
|
||||
|
||||
ENTRYPOINT ["./rogueserver"]
|
|
@ -0,0 +1,27 @@
|
|||
services:
|
||||
server:
|
||||
image: ghcr.io/pagefaultgames/pokerogue:latest
|
||||
command: --debug --dbaddr db:3306 --dbuser pokerogue --dbpass pokerogue --dbname pokeroguedb
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- db
|
||||
networks:
|
||||
- internal
|
||||
ports:
|
||||
- "8001:8001"
|
||||
db:
|
||||
image: mariadb:11
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: admin
|
||||
MYSQL_DATABASE: pokeroguedb
|
||||
MYSQL_USER: pokerogue
|
||||
MYSQL_PASSWORD: pokerogue
|
||||
volumes:
|
||||
- database:/var/lib/mysql
|
||||
|
||||
volumes:
|
||||
database:
|
||||
|
||||
networks:
|
||||
internal:
|
Loading…
Reference in New Issue