Skip to content

Commit

Permalink
ci: add docker build workflow for app
Browse files Browse the repository at this point in the history
  • Loading branch information
ZerNico committed Mar 5, 2025
1 parent 9e202d9 commit 28027ed
Show file tree
Hide file tree
Showing 10 changed files with 137 additions and 7 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/docker-build-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Build and Publish App Docker Image

on:
push:
branches:
- main
- 'feature/**'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/tuneperfect-app

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

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=ref,event=branch,enable=${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }}
type=sha,format=short
type=sha,format=long
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{major}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: apps/app/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/tauri-build-game.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
if: matrix.platform.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libglib2.0-dev
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libglib2.0-dev alsa-base alsa-utils
- name: Setup Bun
uses: oven-sh/setup-bun@v2
Expand All @@ -46,7 +46,7 @@ jobs:
uses: swatinem/rust-cache@v2
with:
workspaces: './apps/game/src-tauri -> target'
key: ${{ matrix.platform.target }}
key: ${{ matrix.platform.target }}-${{ matrix.platform.os }}-game

- name: Install dependencies
run: bun install
Expand Down
1 change: 1 addition & 0 deletions apps/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ COPY ./package.json ./bun.lock ./turbo.json ./
RUN bun install
RUN bun run build --filter @tuneperfect/api


FROM oven/bun:1 AS runner

WORKDIR /usr/src/app
Expand Down
33 changes: 33 additions & 0 deletions apps/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM oven/bun:1 AS builder

WORKDIR /usr/src/app

COPY ./apps/api ./apps/api
COPY ./apps/app ./apps/app
COPY ./packages/email ./packages/email
COPY ./package.json ./bun.lock ./turbo.json ./

RUN bun install
RUN bun run build --filter @tuneperfect/app


FROM nginx:alpine AS runner

RUN apk add --no-cache curl bash
RUN curl -fsSL https://bun.sh/install | bash
ENV BUN_INSTALL="/root/.bun"
ENV PATH="$BUN_INSTALL/bin:$PATH"

WORKDIR /app
RUN bun install @import-meta-env/cli
COPY ./apps/app/.env.example ./
COPY ./apps/app/docker/entrypoint.sh ./entrypoint.sh
RUN chmod +x ./entrypoint.sh

WORKDIR /usr/share/nginx/html
COPY --from=builder /usr/src/app/apps/app/dist ./
COPY ./apps/app/docker/nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80

CMD ["/app/entrypoint.sh"]
5 changes: 5 additions & 0 deletions apps/app/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

bun --bun /app/node_modules/.bin/import-meta-env -x /app/.env.example -p /usr/share/nginx/html/index.html

nginx -g "daemon off;"
12 changes: 12 additions & 0 deletions apps/app/docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
server {
listen 80;

server_name localhost;

root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri /index.html;
}
}
5 changes: 4 additions & 1 deletion apps/app/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link rel="shortcut icon" type="image/ico" href="/src/assets/favicon.ico" />
<title>Tune Perfect</title>
<script>
globalThis.import_meta_env = JSON.parse('"import_meta_env_placeholder"');
</script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
1 change: 1 addition & 0 deletions apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@iconify-json/circle-flags": "^1.2.6",
"@iconify-json/logos": "^1.2.4",
"@iconify-json/lucide": "^1.2.24",
"@import-meta-env/unplugin": "^0.6.2",
"@tailwindcss/vite": "^4.0.0",
"@tuneperfect/api": "*",
"tailwindcss": "^4.0.0",
Expand Down
12 changes: 11 additions & 1 deletion apps/app/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import importMetaEnv from "@import-meta-env/unplugin";
import tailwindcss from "@tailwindcss/vite";
import icons from "unplugin-icons/vite";
import { defineConfig } from "vite";
import pages from "vite-plugin-pages";
import solid from "vite-plugin-solid";

export default defineConfig({
plugins: [solid(), tailwindcss(), pages(), icons({ compiler: "solid" })],
plugins: [
importMetaEnv.vite({
example: ".env.example",
env: ".env",
}),
solid(),
tailwindcss(),
pages(),
icons({ compiler: "solid" }),
],
server: {
port: 3001,
},
Expand Down
11 changes: 8 additions & 3 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@iconify-json/circle-flags": "^1.2.6",
"@iconify-json/logos": "^1.2.4",
"@iconify-json/lucide": "^1.2.24",
"@import-meta-env/unplugin": "^0.6.2",
"@tailwindcss/vite": "^4.0.0",
"@tuneperfect/api": "*",
"tailwindcss": "^4.0.0",
Expand All @@ -64,7 +65,7 @@
},
},
"apps/game": {
"name": "game",
"name": "@tuneperfect/game",
"dependencies": {
"@fontsource/lato": "^5.1.1",
"@nokijs/client": "^0.0.1-alpha.36",
Expand Down Expand Up @@ -378,6 +379,8 @@

"@img/sharp-win32-x64": ["@img/sharp-win32-x64@0.33.5", "", { "os": "win32", "cpu": "x64" }, "sha512-MpY/o8/8kj+EcnxwvrP4aTJSWw/aZ7JIGR4aBeZkZw5B7/Jn+tY9/VNwtcoGmdT7GfggGIU4kygOMSbYnOrAbg=="],

"@import-meta-env/unplugin": ["@import-meta-env/unplugin@0.6.2", "", { "dependencies": { "dotenv": "^16.0.0", "magic-string": "^0.30.0", "object-hash": "^3.0.0", "picocolors": "^1.0.0", "unplugin": "^2.0.0" }, "peerDependencies": { "@import-meta-env/cli": "^0.7.0" }, "optionalPeers": ["@import-meta-env/cli"] }, "sha512-m8TEQTgWekSkhlT9lkHBKQ4TDf5l8+BWvO6q/cxcsv1AvyfsOXUOHbvjhKSiVDaz/CDDCbOWc/aOAiPFRzcXGA=="],

"@internationalized/date": ["@internationalized/date@3.7.0", "", { "dependencies": { "@swc/helpers": "^0.5.0" } }, "sha512-VJ5WS3fcVx0bejE/YHfbDKR/yawZgKqn/if+oEeLqNwBtPzVB06olkfcnojTmEMX+gTpH+FlQ69SHNitJ8/erQ=="],

"@internationalized/number": ["@internationalized/number@3.6.0", "", { "dependencies": { "@swc/helpers": "^0.5.0" } }, "sha512-PtrRcJVy7nw++wn4W2OuePQQfTqDzfusSuY1QTtui4wa7r+rGVtR75pO8CyKvHvzyQYi3Q1uO5sY0AsB4e65Bw=="],
Expand Down Expand Up @@ -764,6 +767,8 @@

"@tuneperfect/email": ["@tuneperfect/email@workspace:packages/email"],

"@tuneperfect/game": ["@tuneperfect/game@workspace:apps/game"],

"@types/babel__core": ["@types/babel__core@7.20.5", "", { "dependencies": { "@babel/parser": "^7.20.7", "@babel/types": "^7.20.7", "@types/babel__generator": "*", "@types/babel__template": "*", "@types/babel__traverse": "*" } }, "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA=="],

"@types/babel__generator": ["@types/babel__generator@7.6.8", "", { "dependencies": { "@babel/types": "^7.0.0" } }, "sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw=="],
Expand Down Expand Up @@ -1288,8 +1293,6 @@

"function-bind": ["function-bind@1.1.2", "", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="],

"game": ["game@workspace:apps/game"],

"gel": ["gel@2.0.1", "", { "dependencies": { "@petamoriken/float16": "^3.8.7", "debug": "^4.3.4", "env-paths": "^3.0.0", "semver": "^7.6.2", "shell-quote": "^1.8.1", "which": "^4.0.0" }, "bin": { "gel": "dist/cli.mjs" } }, "sha512-gfem3IGvqKqXwEq7XseBogyaRwGsQGuE7Cw/yQsjLGdgiyqX92G1xENPCE0ltunPGcsJIa6XBOTx/PK169mOqw=="],

"gensync": ["gensync@1.0.0-beta.2", "", {}, "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg=="],
Expand Down Expand Up @@ -1636,6 +1639,8 @@

"object-assign": ["object-assign@4.1.1", "", {}, "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="],

"object-hash": ["object-hash@3.0.0", "", {}, "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw=="],

"object-inspect": ["object-inspect@1.13.4", "", {}, "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew=="],

"obuf": ["obuf@1.1.2", "", {}, "sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg=="],
Expand Down

0 comments on commit 28027ed

Please sign in to comment.