mirror of
https://github.com/0x2E/fusion.git
synced 2025-06-08 05:27:15 +09:00
update CI (#163)
* cross-compile in ci * build docker image for main branch * default to github registry
This commit is contained in:
parent
74b4d0d35d
commit
6a4e99d0fa
6 changed files with 27 additions and 13 deletions
10
.github/workflows/docker.yml
vendored
10
.github/workflows/docker.yml
vendored
|
@ -3,6 +3,9 @@ name: docker
|
|||
on:
|
||||
release:
|
||||
types: [published]
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
|
@ -25,9 +28,10 @@ jobs:
|
|||
rook1e404/fusion
|
||||
ghcr.io/${{ env.REPOSITORY }}
|
||||
tags: |
|
||||
type=semver,pattern={{version}}
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
# on release: tag with version (e.g., v1.2.3)
|
||||
type=semver,pattern={{version}},enable=${{ github.event_name == 'release' }}
|
||||
# on push to main: tag with main
|
||||
type=raw,value=main,enable=${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Login to Docker Hub
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# build frontend
|
||||
FROM node:23 as fe
|
||||
FROM node:23 AS fe
|
||||
WORKDIR /src
|
||||
RUN npm i -g pnpm
|
||||
COPY .git .git/
|
||||
|
@ -8,11 +8,14 @@ COPY scripts.sh .
|
|||
RUN ./scripts.sh build-frontend
|
||||
|
||||
# build backend
|
||||
FROM golang:1.24 as be
|
||||
FROM golang:1.24 AS be
|
||||
# Add Arguments for target OS and architecture (provided by buildx)
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
WORKDIR /src
|
||||
COPY . ./
|
||||
COPY --from=fe /src/frontend/build ./frontend/build/
|
||||
RUN ./scripts.sh build-backend
|
||||
RUN ./scripts.sh build-backend ${TARGETOS} ${TARGETARCH}
|
||||
|
||||
# deploy
|
||||
FROM alpine:3.21.0
|
||||
|
|
|
@ -19,13 +19,17 @@ Key features include:
|
|||
|
||||
### Docker
|
||||
|
||||
> Use `latest` tag for the latest release version.
|
||||
>
|
||||
> Use `main` tag for the latest development version.
|
||||
|
||||
- Docker CLI
|
||||
|
||||
```shell
|
||||
docker run -it -d -p 8080:8080 \
|
||||
-v $(pwd)/fusion:/data \
|
||||
-e PASSWORD="fusion" \
|
||||
rook1e404/fusion:latest
|
||||
ghcr.io/0x2e/fusion:latest
|
||||
```
|
||||
|
||||
- Docker Compose
|
||||
|
@ -34,7 +38,7 @@ docker run -it -d -p 8080:8080 \
|
|||
version: '3'
|
||||
services:
|
||||
fusion:
|
||||
image: rook1e404/fusion:latest
|
||||
image: ghcr.io/0x2e/fusion:latest
|
||||
ports:
|
||||
- '127.0.0.1:8080:8080'
|
||||
environment:
|
||||
|
|
2
fly.toml
2
fly.toml
|
@ -7,7 +7,7 @@ app = "{APP_NAME}"
|
|||
primary_region = "{REGION}"
|
||||
|
||||
[build]
|
||||
image = 'rook1e404/fusion:latest'
|
||||
image = 'ghcr.io/0x2e/fusion:latest'
|
||||
|
||||
[http_service]
|
||||
internal_port = 8080
|
||||
|
|
|
@ -36,8 +36,10 @@ build_frontend() {
|
|||
}
|
||||
|
||||
build_backend() {
|
||||
echo "building backend"
|
||||
CGO_ENABLED=0 go build \
|
||||
target_os=${1:-$(go env GOOS)}
|
||||
target_arch=${2:-$(go env GOARCH)}
|
||||
echo "building backend for OS: ${target_os}, Arch: ${target_arch}"
|
||||
CGO_ENABLED=0 GOOS=${target_os} GOARCH=${target_arch} go build \
|
||||
-ldflags '-extldflags "-static"' \
|
||||
-o ./build/fusion \
|
||||
./cmd/server/*
|
||||
|
@ -66,7 +68,8 @@ case $1 in
|
|||
build_frontend
|
||||
;;
|
||||
"build-backend")
|
||||
build_backend
|
||||
# Pass along additional arguments ($2, $3) to the function
|
||||
build_backend "$2" "$3"
|
||||
;;
|
||||
"build")
|
||||
build
|
||||
|
|
|
@ -38,7 +38,7 @@ spec:
|
|||
domainKey: PUBLIC_DOMAIN
|
||||
spec:
|
||||
source:
|
||||
image: rook1e404/fusion
|
||||
image: ghcr.io/0x2e/fusion
|
||||
ports:
|
||||
- id: web
|
||||
port: 8080
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue