add docker build action
Some checks failed
Release / build (push) Has been cancelled

This commit is contained in:
2023-01-16 22:58:45 +08:00
parent 529ef40a82
commit a2e5b9d24d
4 changed files with 46 additions and 2 deletions

View File

@@ -35,6 +35,7 @@ jobs:
trimpath: true
- name: Create ZIP archive
if: startsWith(github.ref, 'refs/tags/')
run: |
cp -v ./config_example.ini ./build || exit 1
pushd build || exit 1
@@ -60,3 +61,24 @@ jobs:
body: For test only
name: ${{ github.ref_name }} Pre Release
files: yggdrasil*.zip*
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
if: startsWith(github.ref, 'refs/tags/')
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
if: startsWith(github.ref, 'refs/tags/')
- name: Login to Docker Hub
uses: docker/login-action@v2
if: startsWith(github.ref, 'refs/tags/')
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
if: startsWith(github.ref, 'refs/tags/')
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: gardel/yggdrasil-go:latest, gardel/yggdrasil-go:${{ github.ref_name }}

15
Dockerfile Normal file
View File

@@ -0,0 +1,15 @@
FROM alpine:latest
LABEL maintainer="Gardel <sunxinao@hotmail.com>"
LABEL "Description"="Go Yggdrasil Server"
ARG TARGETOS
ARG TARGETARCH
RUN mkdir -p /app
COPY "build/yggdrasil-${TARGETOS}-${TARGETARCH}" /app/yggdrasil
EXPOSE 8080
VOLUME /app/data
WORKDIR /app/data
ENTRYPOINT ["/app/yggdrasil"]

View File

@@ -1,5 +1,5 @@
GO_CMD ?= go
GO_BUILD = $(GO_CMD) build -trimpath -ldflags "-s -w"
GO_BUILD = $(GO_CMD) build -trimpath -ldflags "-s -w -buildid="
GO_CLEAN = $(GO_CMD) clean
GO_TEST = $(GO_CMD) test
GO_GET = $(GO_CMD) get
@@ -11,7 +11,7 @@ PACKAGE_NAME = yggdrasil.tar.gz
default: $(BINARY)
$(BINARY):
$(GO_BUILD) -tags=nomsgpack -o $(BINARY)
$(GO_BUILD) -tags='nomsgpack,sqlite,mysql' -o $(BINARY)
get:
$(GO_GET)

View File

@@ -26,3 +26,10 @@
注册地址在 `/profile/index.html`
## Docker
使用 docker 快速上手:
```shell
docker run -d --name yggdrasil-go -v $(pwd)/data:/app/data -p 8080:8080 gardel/yggdrasil-go:latest
```