Skip to content

Commit 7560b43

Browse files
authored
Merge pull request #24 from HugoRCD/epi-65
Epi 65
2 parents eb0417a + d0839b2 commit 7560b43

File tree

9 files changed

+247
-4
lines changed

9 files changed

+247
-4
lines changed

.github/workflows/build-app-image.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build and Push Application Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
workflow_dispatch:
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
jobs:
16+
check-changes:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
src: ${{ steps.changes.outputs.src }}
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Check if there are changes
25+
uses: dorny/paths-filter@v3
26+
id: changes
27+
with:
28+
filters: |
29+
src:
30+
- 'apps/docs/**'
31+
- 'packages/nuxt/**'
32+
- 'packages/utils/**'
33+
- 'bun.lockb'
34+
35+
build-and-push:
36+
needs: check-changes
37+
if: needs.check-changes.outputs.src == 'true'
38+
runs-on: ubuntu-latest
39+
permissions:
40+
contents: read
41+
packages: write
42+
43+
steps:
44+
- name: Checkout repository
45+
uses: actions/checkout@v4
46+
47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v3
49+
50+
- name: Log in to GitHub Container Registry
51+
uses: docker/login-action@v3
52+
with:
53+
registry: ${{ env.REGISTRY }}
54+
username: ${{ github.actor }}
55+
password: ${{ secrets.GITHUB_TOKEN }}
56+
57+
- name: Extract metadata for Docker
58+
id: meta
59+
uses: docker/metadata-action@v5
60+
with:
61+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
62+
tags: |
63+
type=ref,event=branch
64+
type=ref,event=pr
65+
type=semver,pattern={{version}}
66+
type=semver,pattern={{major}}.{{minor}}
67+
type=sha,format=long
68+
type=raw,value=latest,enable={{is_default_branch}}
69+
70+
- name: Build and push Docker image
71+
uses: docker/build-push-action@v6
72+
with:
73+
context: .
74+
file: ./apps/currencia/Dockerfile
75+
push: true
76+
tags: ${{ steps.meta.outputs.tags }}
77+
labels: ${{ steps.meta.outputs.labels }}
78+
cache-from: type=gha
79+
cache-to: type=gha,mode=max
80+
build-args: |
81+
TURBO_TEAM=${{ vars.TURBO_TEAM }}
82+
TURBO_TOKEN=${{ secrets.TURBO_TOKEN }}
83+
DATABASE_URL=${{ secrets.DATABASE_URL }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ logs
2020
# Local env files
2121
.env
2222
.vercel
23+
.turbo

apps/currencia/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Stage 1: Build Stage
2+
FROM oven/bun:latest AS build
3+
4+
ARG DATABASE_URL
5+
ARG TURBO_TEAM
6+
ARG TURBO_TOKEN
7+
8+
ENV DATABASE_URL=$DATABASE_URL
9+
ENV TURBO_TEAM=$TURBO_TEAM
10+
ENV TURBO_TOKEN=$TURBO_TOKEN
11+
ENV NODE_ENV=production
12+
13+
WORKDIR /app
14+
15+
COPY package.json ./
16+
COPY bun.lockb ./
17+
18+
COPY apps/currencia/package.json ./apps/currencia/package.json
19+
20+
COPY . .
21+
22+
RUN bun install
23+
24+
RUN bun run build:app
25+
26+
# Stage 2: Final Stage
27+
FROM oven/bun:latest
28+
29+
WORKDIR /app
30+
31+
COPY --from=build /app/apps/currencia/.output .output
32+
COPY --from=build /app/apps/currencia/prisma ./prisma
33+
34+
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
35+
36+
EXPOSE 3000
37+
38+
CMD ["bun", "run", ".output/server/index.mjs"]

apps/currencia/nuxt.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export default defineNuxtConfig({
4646
},
4747

4848
nitro: {
49+
preset: process.env.NITRO_PRESET || 'bun',
4950
prerender: {
5051
crawlLinks: true,
5152
routes: ['/', '/app/market'],

bun.lockb

2.63 KB
Binary file not shown.

docker/.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Generated by Shelve CLI
2+
3+
# Auto generated if not set
4+
NUXT_PUBLIC_SITE_URL=your_value

docker/docker-compose.local.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
services:
2+
currencia:
3+
build:
4+
context: ../
5+
dockerfile: ./apps/currencia/Dockerfile
6+
container_name: currencia
7+
restart: always
8+
environment:
9+
- DATABASE_URL=${DATABASE_URL:-postgres://postgres:postgres@currencia_db:5432/postgres}
10+
- NUXT_OAUTH_GITHUB_CLIENT_ID=${NUXT_OAUTH_GITHUB_CLIENT_ID}
11+
- NUXT_OAUTH_GITHUB_CLIENT_SECRET=${NUXT_OAUTH_GITHUB_CLIENT_SECRET}
12+
- NUXT_SESSION_PASSWORD=${NUXT_SESSION_PASSWORD}
13+
- NUXT_PRIVATE_RESEND_API_KEY=${NUXT_PRIVATE_RESEND_API_KEY}
14+
depends_on:
15+
- currencia_db
16+
ports:
17+
- "3000:3000"
18+
healthcheck:
19+
test: [ "CMD", "curl", "-f", "http://localhost:3000/api/hello" ]
20+
interval: 30s
21+
timeout: 10s
22+
retries: 3
23+
logging:
24+
driver: "json-file"
25+
options:
26+
max-size: "10m"
27+
max-file: "3"
28+
deploy:
29+
resources:
30+
limits:
31+
cpus: '1'
32+
memory: 1G
33+
reservations:
34+
cpus: '0.5'
35+
memory: 512M
36+
currencia_db:
37+
image: postgres:15.4
38+
container_name: currencia_db
39+
restart: always
40+
environment:
41+
- POSTGRES_USER=postgres
42+
- POSTGRES_PASSWORD=postgres
43+
- POSTGRES_DB=postgres
44+
ports:
45+
- "5436:5432"
46+
healthcheck:
47+
test: [ "CMD", "pg_isready", "-U", "postgres" ]
48+
interval: 30s
49+
timeout: 10s
50+
retries: 3
51+
logging:
52+
driver: "json-file"
53+
options:
54+
max-size: "10m"
55+
max-file: "3"
56+
deploy:
57+
resources:
58+
limits:
59+
cpus: '1'
60+
memory: 1G
61+
reservations:
62+
cpus: '0.5'
63+
memory: 512M

package.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,22 @@
66
"private": true,
77
"type": "module",
88
"scripts": {
9-
"dev": "bun --filter './apps/*' dev",
10-
"lint": "eslint .",
11-
"lint:fix": "eslint --fix ."
9+
"dev": "turbo dev --filter=@currencia/app",
10+
"run:scripts": "turbo dev --filter='./scripts/*'",
11+
"build": "turbo build",
12+
"build:app": "turbo build --filter=@currencia/app",
13+
"test": "turbo test",
14+
"dev:prepare": "turbo dev:prepare",
15+
"lint": "turbo lint",
16+
"lint:fix": "turbo lint:fix",
17+
"typecheck": "tsc --noEmit"
1218
},
1319
"dependencies": {
1420
"@hrcd/eslint-config": "^2.1.1",
15-
"eslint": "^9.14.0"
21+
"eslint": "^9.14.0",
22+
"turbo": "^2.2.3"
1623
},
24+
"packageManager": "bun@1.1.34",
1725
"workspaces": [
1826
"apps/*",
1927
"packages/*",

turbo.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"$schema": "https://turbo.build/schema.json",
3+
"globalDependencies": [
4+
"**/.env"
5+
],
6+
"tasks": {
7+
"build": {
8+
"dependsOn": [
9+
"^build"
10+
],
11+
"outputs": [
12+
"dist/**",
13+
".output/**",
14+
".nuxt/**"
15+
]
16+
},
17+
"generate": {
18+
"dependsOn": [
19+
"^generate"
20+
],
21+
"outputs": [
22+
"dist/**",
23+
".output/**",
24+
".nuxt/**"
25+
]
26+
},
27+
"dev": {
28+
"cache": false,
29+
"persistent": true
30+
},
31+
"dev:prepare": {
32+
"cache": false,
33+
"outputs": [
34+
"dist/**",
35+
".output/**",
36+
".nuxt/**"
37+
]
38+
},
39+
"prisma:generate": {},
40+
"lint": {},
41+
"lint:fix": {},
42+
"test": {},
43+
"typecheck": {}
44+
}
45+
}

0 commit comments

Comments
 (0)