Skip to content

Commit

Permalink
ci: add build github action (#8)
Browse files Browse the repository at this point in the history
* ci: add build github action

* ci: add sentry release/sourcemap integration
fix: OOM when building app
  • Loading branch information
rmoesbergen authored May 2, 2024
1 parent 0627d18 commit c24532b
Show file tree
Hide file tree
Showing 6 changed files with 643 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
dist/
.git/
.env*
.github/
45 changes: 45 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Deploy

on:
push:
tags:
- v*
branches:
- main
workflow_dispatch: {}

jobs:
push:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Docker Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push TEST Docker image
if: github.ref_type == 'branch'
uses: docker/build-push-action@v5
with:
file: Dockerfile
context: .
push: true
tags: ghcr.io/leaphy-robotics/leaphy-webbased-svelte/leaphy-webbased-svelte:test

- name: Redeploy TEST
if: github.ref_type == 'branch'
run: |
curl https://admin.leaphyeasybloqs.com/hooks/update-docker-image?stack=leaphy-webbased-svelte -H "X-Token: ${{ secrets.WEBHOOK_TOKEN }}"
- name: Clean up old images
uses: actions/delete-package-versions@v5
with:
package-name: "leaphy-webbased/leaphy-webbased-svelte"
package-type: "container"
min-versions-to-keep: 5
delete-only-untagged-versions: "true"
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:20 as builder

COPY . /build
WORKDIR /build

# Prevent vite build OOM
ENV NODE_OPTIONS="--max-old-space-size=4096"

RUN yarn install --frozen-lockfile && yarn build

FROM nginx:stable

COPY --from=builder /build/dist /usr/share/nginx/html
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"check": "svelte-check --tsconfig ./tsconfig.json"
},
"devDependencies": {
"@sentry/vite-plugin": "^2.16.1",
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"@tsconfig/svelte": "^5.0.2",
"@types/node": "^20.11.30",
Expand Down
14 changes: 13 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import path from 'path'
import { viteStaticCopy } from 'vite-plugin-static-copy'
import { sentryVitePlugin } from "@sentry/vite-plugin";
import topLevelAwait from "vite-plugin-top-level-await";

// https://vitejs.dev/config/
Expand Down Expand Up @@ -33,7 +34,15 @@ export default defineConfig({
dest: 'picotool'
},
]
})],
}),
// Upload source maps to Sentry
sentryVitePlugin({
url: "https://leaphyeasybloqs.com:8443/",
project: "leaphy-webbased-svelte",
org: 'leaphy',
authToken: process.env.SENTRY_AUTH_TOKEN,
})
],
resolve: {
alias: {
$components: path.resolve(__dirname, './src/lib/components'),
Expand All @@ -48,5 +57,8 @@ export default defineConfig({
"Cross-Origin-Embedder-Policy": "require-corp",
"Cross-Origin-Opener-Policy": "same-origin"
}
},
build: {
sourcemap: true
}
})
Loading

0 comments on commit c24532b

Please sign in to comment.