Skip to content

Commit

Permalink
Merge pull request #178 from hearchco/revert-remove-node-docker
Browse files Browse the repository at this point in the history
ci(docker): revert removing Dockerfile with node adapter
  • Loading branch information
aleksasiriski authored Mar 28, 2024
2 parents fc1271c + 78bbd62 commit 9e7e67a
Show file tree
Hide file tree
Showing 10 changed files with 496 additions and 216 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ updates:
directory: '/'
schedule:
interval: 'daily'
- package-ecosystem: 'docker'
directory: '/'
schedule:
interval: 'daily'
- package-ecosystem: 'npm'
directory: '/'
schedule:
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/dockercicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Docker CI

on:
push:
branches: ['main']
tags: ['v*.*.*']
pull_request:
branches: ['main']

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4

# switch svelte.config.js to node
- run: make node

# install deps (using pnpm until bun fixes bug for static assets)
- uses: pnpm/action-setup@v3
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: 'pnpm'
- run: make install

# build project
- run: make build

# setup docker (arm64)
- uses: docker/setup-qemu-action@v3
with:
platforms: arm64

- uses: docker/setup-buildx-action@v3

- uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# build docker
- uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: |-
linux/amd64
linux/arm64
4 changes: 2 additions & 2 deletions .github/workflows/testingci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ jobs:
with:
node-version: lts/*
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: make install

- run: pnpm run build
- run: make build
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.12.0
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ build:
pnpm run build

preview:
pnpm run preview
pnpm run preview

cf:
cp svelte.config.cf.js svelte.config.js

node:
cp svelte.config.node.js svelte.config.js
11 changes: 11 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM cgr.dev/chainguard/node-lts:latest

ENV NODE_ENV=production

COPY --chown=node:node ["package.json", "build/", "./"]

CMD [ "index.js" ]

EXPOSE 3000

LABEL org.opencontainers.image.source="https://github.com/hearchco/frontend"
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
},
"devDependencies": {
"@sveltejs/adapter-cloudflare": "^4.2.0",
"@sveltejs/adapter-node": "^5.0.1",
"@sveltejs/kit": "^2.5.4",
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^6.21.0",
"autoprefixer": "^10.4.19",
"eslint": "^8.57.0",
Expand Down
Loading

0 comments on commit 9e7e67a

Please sign in to comment.