This commit is contained in:
47
.gitea/workflows/build.yaml
Normal file
47
.gitea/workflows/build.yaml
Normal file
@@ -0,0 +1,47 @@
|
||||
name: Build and Push
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main # Триггер на пуш в ветку main
|
||||
tags:
|
||||
- 'v*' # Триггер на теги, начинающиеся с 'v'
|
||||
|
||||
env:
|
||||
HARBOR_REGISTRY: harbor.grachevko.ru # Адрес вашего Harbor
|
||||
HARBOR_PROJECT: obsidian # Название проекта в Harbor
|
||||
IMAGE_NAME: server # Название образа
|
||||
DOCKERFILE_PATH: ./Dockerfile # Путь к Dockerfile
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Login to Harbor
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.HARBOR_REGISTRY }}
|
||||
username: ${{ secrets.HARBOR_USERNAME }}
|
||||
password: ${{ secrets.HARBOR_PASSWORD }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.HARBOR_REGISTRY }}/${{ env.HARBOR_PROJECT }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
type=sha
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: ${{ env.DOCKERFILE_PATH }}
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
||||
FROM golang:1.24.5-alpine
|
||||
|
||||
ENV CGO_ENABLED=0
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY . .
|
27
main.go
Normal file
27
main.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
//go:embed public/*
|
||||
var publicFS embed.FS
|
||||
|
||||
func main() {
|
||||
// Получаем подпапку 'public' из embed.FS
|
||||
pub, err := fs.Sub(publicFS, "public")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Создаем файловый сервер с корнем в подпапке public
|
||||
fileServer := http.FileServer(http.FS(pub))
|
||||
|
||||
http.Handle("/", fileServer)
|
||||
|
||||
log.Println("Server starting on :8080")
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
}
|
0
public/.gitkeep
Normal file
0
public/.gitkeep
Normal file
Reference in New Issue
Block a user