Skip to content

Commit

Permalink
add docker build action
Browse files Browse the repository at this point in the history
  • Loading branch information
Gardelll committed Jan 16, 2023
1 parent 529ef40 commit a2e5b9d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

0 comments on commit a2e5b9d

Please sign in to comment.