Image with backend & frontend
Backend docker image / release-image (push) Failing after 12s Details
Frontend docker image / release-image (push) Has been cancelled Details
Frontend and backend docker image / release-image (push) Has been cancelled Details

This commit is contained in:
Brieuc Dubois 2024-01-10 00:39:55 +01:00
parent 2c6182ad7c
commit 25cb93c356
6 changed files with 105 additions and 1 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

@ -0,0 +1,51 @@
name: Frontend and backend docker image
run-name: ${{ gitea.actor }} is runs ci pipeline
on:
push:
branches:
- master
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 }}

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"]

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