Skip to content

Commit 2ad48d0

Browse files
Na-Clybarelyhuman
andauthored
Add docker image workflow (#23)
* Create docker-publish.yml * Add files via upload * fix: Dockerfile build also lock versions for node * docs: update readme - partial * Update Dockerfile --------- Co-authored-by: Reaper Gelera <[email protected]>
1 parent 1069ac1 commit 2ad48d0

File tree

4 files changed

+114
-0
lines changed

4 files changed

+114
-0
lines changed

.github/workflows/docker-publish.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Docker
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
8+
on:
9+
push:
10+
branches: [ "pro" ]
11+
# Publish semver tags as releases.
12+
tags: [ 'v*.*.*' ]
13+
pull_request:
14+
branches: [ "pro" ]
15+
16+
env:
17+
# Use docker.io for Docker Hub if empty
18+
REGISTRY: ghcr.io
19+
# github.repository as <account>/<repo>
20+
IMAGE_NAME: ${{ github.repository }}
21+
22+
23+
jobs:
24+
build:
25+
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: read
29+
packages: write
30+
# This is used to complete the identity challenge
31+
# with sigstore/fulcio when running outside of PRs.
32+
id-token: write
33+
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
37+
38+
# Install the cosign tool except on PR
39+
# https://github.com/sigstore/cosign-installer
40+
- name: Install cosign
41+
if: github.event_name != 'pull_request'
42+
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
43+
with:
44+
cosign-release: 'v2.2.4'
45+
46+
# Set up BuildKit Docker container builder to be able to build
47+
# multi-platform images and export cache
48+
# https://github.com/docker/setup-buildx-action
49+
- name: Set up Docker Buildx
50+
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
51+
52+
# Login against a Docker registry except on PR
53+
# https://github.com/docker/login-action
54+
- name: Log into registry ${{ env.REGISTRY }}
55+
if: github.event_name != 'pull_request'
56+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
57+
with:
58+
registry: ${{ env.REGISTRY }}
59+
username: ${{ github.actor }}
60+
password: ${{ secrets.GITHUB_TOKEN }}
61+
62+
# Extract metadata (tags, labels) for Docker
63+
# https://github.com/docker/metadata-action
64+
- name: Extract Docker metadata
65+
id: meta
66+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
67+
with:
68+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
69+
70+
# Build and push Docker image with Buildx (don't push on PR)
71+
# https://github.com/docker/build-push-action
72+
- name: Build and push Docker image
73+
id: build-and-push
74+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
75+
with:
76+
context: .
77+
push: ${{ github.event_name != 'pull_request' }}
78+
tags: ${{ steps.meta.outputs.tags }}
79+
labels: ${{ steps.meta.outputs.labels }}
80+
cache-from: type=gha
81+
cache-to: type=gha,mode=max
82+
83+
# Sign the resulting Docker image digest except on PRs.
84+
# This will only write to the public Rekor transparency log when the Docker
85+
# repository is public to avoid leaking data. If you would like to publish
86+
# transparency data even for private images, pass --force to cosign below.
87+
# https://github.com/sigstore/cosign
88+
- name: Sign the published Docker image
89+
if: ${{ github.event_name != 'pull_request' }}
90+
env:
91+
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
92+
TAGS: ${{ steps.meta.outputs.tags }}
93+
DIGEST: ${{ steps.build-and-push.outputs.digest }}
94+
# This step uses the identity token to provision an ephemeral certificate
95+
# against the sigstore community Fulcio instance.
96+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

.nvmrc

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

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM node:18-alpine as build-stage
2+
WORKDIR /app
3+
COPY package*.json ./
4+
COPY pnpm-lock.yaml ./
5+
RUN npm i -g [email protected]; pnpm i
6+
COPY . .
7+
RUN pnpm build
8+
9+
FROM nginx:stable-alpine as production-stage
10+
COPY --from=build-stage /app/dist /usr/share/nginx/html
11+
EXPOSE 80
12+
CMD ["nginx", "-g", "daemon off;"]

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ Simple Markdown editor built with syntax highlighting and an optional preview th
1515

1616
## Development / Self Hosting
1717

18+
### Docker
19+
TBD
20+
21+
### Manually using Source Code
22+
1823
The app is a straightforward vuejs app and just a client sided one. You can set it up using the following steps.
1924

2025
**Prerequisite**

0 commit comments

Comments
 (0)