Skip to content

Commit 7d5b3cd

Browse files
committed
feat: publish docker image
1 parent 5e7afbf commit 7d5b3cd

File tree

4 files changed

+65
-4
lines changed

4 files changed

+65
-4
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.github/workflows/release.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
token: ${{ secrets.GITHUB_TOKEN }}
2424
release-type: node
2525

26-
release:
26+
release-assets:
2727
needs: release-please
2828
runs-on: ubuntu-latest
2929
if: ${{ needs.release-please.outputs.release_created }}
@@ -45,22 +45,56 @@ jobs:
4545
- name: build for gh-pages
4646
run: pnpm build --base /metacubexd
4747

48-
- name: publish github pages
48+
- name: publish gh-pages
4949
uses: peaceiris/actions-gh-pages@v3
5050
with:
5151
github_token: ${{ secrets.GITHUB_TOKEN }}
5252
publish_dir: ./dist
5353

54-
- name: build for release
54+
- name: build for github release
5555
run: pnpm build
5656

5757
- name: zip
5858
run: |
5959
zip -r ../dist.zip .
6060
working-directory: dist
6161

62-
- name: attach release artifacts
62+
- name: attach github release artifacts
6363
uses: softprops/action-gh-release@v1
6464
with:
6565
files: dist.zip
6666
tag_name: ${{ needs.release-please.outputs.tag_name }}
67+
68+
release-image:
69+
needs: release-please
70+
runs-on: ubuntu-latest
71+
if: ${{ needs.release-please.outputs.release_created }}
72+
steps:
73+
- uses: actions/checkout@v3
74+
75+
- name: set up QEMU
76+
uses: docker/setup-qemu-action@v2
77+
78+
- name: set up docker buildx
79+
uses: docker/setup-buildx-action@v2
80+
id: buildx
81+
82+
- name: login to ghrc.io
83+
uses: docker/login-action@v2
84+
with:
85+
registry: ghcr.io
86+
username: ${{ github.actor }}
87+
password: ${{ secrets.GITHUB_TOKEN }}
88+
89+
- name: build and publish ghcr.io docker image
90+
uses: docker/build-push-action@v4
91+
with:
92+
context: .
93+
builder: ${{ steps.buildx.outputs.name }}
94+
file: Dockerfile
95+
platforms: linux/amd64
96+
push: true
97+
tags: |
98+
ghcr.io/${{ github.repository }}:latest
99+
cache-from: type=gha
100+
cache-to: type=gha,mode=max

Caddyfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
:80 {
2+
file_server
3+
4+
root * .
5+
6+
try_files {path} /index.html
7+
}

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM docker.io/node:alpine as builder
2+
3+
WORKDIR /build
4+
5+
COPY . .
6+
7+
RUN corepack enable
8+
RUN corepack prepare pnpm@latest --activate
9+
RUN pnpm install
10+
RUN pnpm build
11+
12+
FROM docker.io/caddy:alpine
13+
14+
WORKDIR /srv
15+
16+
COPY --from=builder /build/dist/. .
17+
COPY Caddyfile .
18+
19+
CMD ["caddy", "run"]

0 commit comments

Comments
 (0)