init
All checks were successful
Build and Push / build-and-push (push) Successful in 1m5s

This commit is contained in:
Konstantin Grachev
2025-07-18 22:20:49 +03:00
commit 4e06ababf3
5 changed files with 84 additions and 0 deletions

View 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
View File

@@ -0,0 +1,7 @@
FROM golang:1.24.5-alpine
ENV CGO_ENABLED=0
WORKDIR /usr/src/app
COPY . .

3
go.mod Normal file
View File

@@ -0,0 +1,3 @@
module server
go 1.24.5

27
main.go Normal file
View 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
View File