feat: publish docker image

This commit is contained in:
kunish 2023-08-30 00:40:47 +08:00
parent 5e7afbf2b4
commit 7d5b3cddcc
No known key found for this signature in database
GPG Key ID: 647A12B4F782C430
4 changed files with 65 additions and 4 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
node_modules

View File

@ -23,7 +23,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
release-type: node release-type: node
release: release-assets:
needs: release-please needs: release-please
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ needs.release-please.outputs.release_created }} if: ${{ needs.release-please.outputs.release_created }}
@ -45,13 +45,13 @@ jobs:
- name: build for gh-pages - name: build for gh-pages
run: pnpm build --base /metacubexd run: pnpm build --base /metacubexd
- name: publish github pages - name: publish gh-pages
uses: peaceiris/actions-gh-pages@v3 uses: peaceiris/actions-gh-pages@v3
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist publish_dir: ./dist
- name: build for release - name: build for github release
run: pnpm build run: pnpm build
- name: zip - name: zip
@ -59,8 +59,42 @@ jobs:
zip -r ../dist.zip . zip -r ../dist.zip .
working-directory: dist working-directory: dist
- name: attach release artifacts - name: attach github release artifacts
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v1
with: with:
files: dist.zip files: dist.zip
tag_name: ${{ needs.release-please.outputs.tag_name }} tag_name: ${{ needs.release-please.outputs.tag_name }}
release-image:
needs: release-please
runs-on: ubuntu-latest
if: ${{ needs.release-please.outputs.release_created }}
steps:
- uses: actions/checkout@v3
- name: set up QEMU
uses: docker/setup-qemu-action@v2
- name: set up docker buildx
uses: docker/setup-buildx-action@v2
id: buildx
- name: login to ghrc.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: build and publish ghcr.io docker image
uses: docker/build-push-action@v4
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
file: Dockerfile
platforms: linux/amd64
push: true
tags: |
ghcr.io/${{ github.repository }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max

7
Caddyfile Normal file
View File

@ -0,0 +1,7 @@
:80 {
file_server
root * .
try_files {path} /index.html
}

19
Dockerfile Normal file
View File

@ -0,0 +1,19 @@
FROM docker.io/node:alpine as builder
WORKDIR /build
COPY . .
RUN corepack enable
RUN corepack prepare pnpm@latest --activate
RUN pnpm install
RUN pnpm build
FROM docker.io/caddy:alpine
WORKDIR /srv
COPY --from=builder /build/dist/. .
COPY Caddyfile .
CMD ["caddy", "run"]