Compare commits

...

2 Commits

Author SHA1 Message Date
Brieuc Dubois b6e36fdf00 Dynamic manifest.json and move projects under project/ 2024-01-10 14:22:43 +01:00
Brieuc Dubois c8edc250a1 Image with backend & frontend
Backend docker image / release-image (push) Successful in 10m1s Details
Frontend and backend docker image / release-image (push) Successful in 15m20s Details
Frontend docker image / release-image (push) Successful in 3m49s Details
2024-01-10 00:46:45 +01:00
12 changed files with 151 additions and 7 deletions

12
.dockerignore Normal file
View File

@ -0,0 +1,12 @@
node_modules
.eslint*
.prettier*
.git*
Dockerfile
docker-compose.yaml
public
.svelte-kot
build
.dockerignore
*.sqlite
*.md

View File

@ -2,8 +2,6 @@ name: Backend docker image
run-name: ${{ gitea.actor }} is runs ci pipeline
on:
push:
branches:
- master
tags:
- "v*"

View File

@ -0,0 +1,49 @@
name: Frontend and backend docker image
run-name: ${{ gitea.actor }} is runs ci pipeline
on:
push:
tags:
- "v*"
jobs:
release-image:
runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract tag
uses: olegtarasov/get-tag@v2.1.2
id: tagName
with:
tagRegex: "v(.*)"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
config-inline: |
[registry."git.bhasher.com"]
http = true
insecure = true
- name: Login
uses: docker/login-action@v2
with:
registry: git.bhasher.com
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push frontend
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
platforms: |
linux/amd64
linux/arm64
tags: |
git.bhasher.com/bhasher/focus:latest
git.bhasher.com/bhasher/focus:${{ steps.tagName.outputs.tag }}

View File

@ -2,8 +2,6 @@ name: Frontend docker image
run-name: ${{ gitea.actor }} is runs ci pipeline
on:
push:
branches:
- master
tags:
- "v*"

33
Dockerfile Normal file
View File

@ -0,0 +1,33 @@
FROM node:20 as frontend-builder
WORKDIR /app
COPY frontend/. .
RUN npm install
RUN npm run build
FROM golang:1.21.5 as backend-builder
WORKDIR /app
COPY backend/. .
RUN CGO_ENABLED=1 GOOS=linux go build -o main
FROM debian:stable-slim
WORKDIR /app
COPY --from=frontend-builder /app /app/frontend
COPY --from=backend-builder /app/main /app/backend/main
RUN apt-get update && apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_20.x | bash -
RUN apt-get install -y nodejs
VOLUME /data
EXPOSE 4173 3000
ENV DB_PATH=/data/db.sqlite
ENV PUBLIC_BACKEND_URL=http://localhost:3000
COPY run.sh /app/run.sh
RUN chmod +x /app/run.sh
CMD ["/app/run.sh"]

View File

@ -6,7 +6,7 @@ import (
var db *sql.DB
const DB_VERSION = 1
const DB_VERSION = 2
func InitDB(driver string, connStr string) error {
var err error

View File

@ -13,4 +13,6 @@ COPY --from=frontend-builder /app .
EXPOSE 4173
ENV PUBLIC_BACKEND_URL=http://localhost:3000
CMD ["npm", "run", "preview", "--", "--port", "4173", "--host", "0.0.0.0"]

View File

@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" href="/css/global.css" />
<title>Focus.</title>
<link rel="manifest" href="/manifest.json" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">

View File

@ -40,10 +40,10 @@
{:else}
<div
class="title"
on:click={() => (location.href = `/${project.id}`)}
on:click={() => (location.href = `/project/${project.id}`)}
on:keydown={(e) => {
if (e.key === 'Enter') {
location.href = `/${project.id}`;
location.href = `/project/${project.id}`;
}
}}
tabindex="0"

View File

@ -0,0 +1,45 @@
import projectsApi from '$lib/api/projectsApi';
interface Shortcut {
name: string;
description: string;
url: string;
icons: {
src: string;
sizes: string;
}[];
}
export async function GET() {
const icon = {
src: '/img/icon.svg',
type: 'image/svg+xml',
sizes: 'any'
};
const projects = await projectsApi.getAll();
const shortcuts: Shortcut[] = projects.map((project) => {
return {
name: `Project ${project.title}`,
description: `Shortcut for project ${project.title}`,
url: `/${project.id}`,
icons: [icon]
};
});
const manifest = {
short_name: 'Focus',
name: 'Focus',
start_url: '/',
display: 'standalone',
icons: [icon],
shortcuts
};
return new Response(JSON.stringify(manifest), {
headers: {
'Content-Type': 'application/manifest+json'
}
});
}

6
run.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash
cd frontend && npm run preview -- --port 4173 --host 0.0.0.0 &
cd backend && ./main &
wait -n