Image with backend & frontend
This commit is contained in:
parent
2c6182ad7c
commit
25cb93c356
|
@ -0,0 +1,12 @@
|
||||||
|
node_modules
|
||||||
|
.eslint*
|
||||||
|
.prettier*
|
||||||
|
.git*
|
||||||
|
Dockerfile
|
||||||
|
docker-compose.yaml
|
||||||
|
public
|
||||||
|
.svelte-kot
|
||||||
|
build
|
||||||
|
.dockerignore
|
||||||
|
*.sqlite
|
||||||
|
*.md
|
|
@ -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 }}
|
|
@ -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"]
|
|
@ -6,7 +6,7 @@ import (
|
||||||
|
|
||||||
var db *sql.DB
|
var db *sql.DB
|
||||||
|
|
||||||
const DB_VERSION = 1
|
const DB_VERSION = 2
|
||||||
|
|
||||||
func InitDB(driver string, connStr string) error {
|
func InitDB(driver string, connStr string) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
|
@ -13,4 +13,6 @@ COPY --from=frontend-builder /app .
|
||||||
|
|
||||||
EXPOSE 4173
|
EXPOSE 4173
|
||||||
|
|
||||||
|
ENV PUBLIC_BACKEND_URL=http://localhost:3000
|
||||||
|
|
||||||
CMD ["npm", "run", "preview", "--", "--port", "4173", "--host", "0.0.0.0"]
|
CMD ["npm", "run", "preview", "--", "--port", "4173", "--host", "0.0.0.0"]
|
||||||
|
|
Loading…
Reference in New Issue