Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build Docker Containers

on:
push:
branches:
- main
paths-ignore:
- "README.md"
- "LICENSE"
- ".gitignore"
workflow_dispatch:

jobs:

build-alpine:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Alpine Dockerfile
id: docker_build
uses: docker/build-push-action@v3.2.0
with:
platforms: linux/arm64,linux/armhf,linux/386,linux/amd64
push: true
tags: |
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:alpine
pull: false
context: .
file: Dockerfile

build-debian:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Debian Dockerfile
id: docker_build
uses: docker/build-push-action@v3.2.0
with:
platforms: linux/arm64,linux/armhf,linux/386,linux/amd64
push: true
tags: |
ghcr.io/${{ github.repository }}:debian
pull: false
context: .
file: Debian_Dockerfile
86 changes: 18 additions & 68 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,78 +1,28 @@
name: Build Docker Containers
name: goreleaser

on:
push:
branches:
- main
paths-ignore:
- "README.md"
- "LICENSE"
- ".gitignore"
workflow_dispatch:
tags:
- "*"

jobs:
permissions:
contents: write

build-alpine:
permissions: write-all
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Alpine Dockerfile
id: docker_build
uses: docker/build-push-action@v3.2.0
- uses: actions/checkout@v3
with:
platforms: linux/arm64,linux/armhf,linux/386,linux/amd64
push: true
tags: |
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:alpine
pull: false
context: .
file: Dockerfile

build-debian:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Container Registry
uses: docker/login-action@v2
fetch-depth: 0
- run: git fetch --force --tags
- uses: actions/setup-go@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Debian Dockerfile
id: docker_build
uses: docker/build-push-action@v3.2.0
go-version: stable
- uses: goreleaser/goreleaser-action@v4
with:
platforms: linux/arm64,linux/armhf,linux/386,linux/amd64
push: true
tags: |
ghcr.io/${{ github.repository }}:debian
pull: false
context: .
file: Debian_Dockerfile
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51 changes: 51 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
before:
hooks:
- go mod tidy -compat=1.20
- go mod vendor

release:
prerelease: auto

builds:
- id: wolweb
mod_timestamp: "{{ .CommitTimestamp }}"
env:
- CGO_ENABLED=0
targets:
- darwin_amd64
- darwin_arm64
- freebsd_amd64
- linux_386
- linux_amd64
- linux_arm64
- linux_arm_5
- linux_arm_6
- linux_arm_7
flags:
- -mod=readonly
ldflags:
- -s -w -X main.Version={{.Version}}

archives:
- id: golang-cross
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}'
format: binary

source:
enabled: true
name_template: "{{ .ProjectName }}_{{ .Version }}"
format: tar.gz
files:
- "vendor/"

checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
17 changes: 7 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,41 @@ import (
"github.com/ilyakaznacheev/cleanenv"
)

var Version = "dev"

// Global variables
var appConfig AppConfig
var appData AppData
var (
appConfig AppConfig
appData AppData
)

func main() {

log.Printf("Starting WakeOnLan Webserver version %s", Version)
setWorkingDir()
loadConfig()
loadData()
setupWebServer()

}

func setWorkingDir() {

thisApp, err := os.Executable()
if err != nil {
log.Fatalf("Error determining the directory. \"%s\"", err)
}
appPath := filepath.Dir(thisApp)
os.Chdir(appPath)
log.Printf("Set working directory: %s", appPath)

}

func loadConfig() {

err := cleanenv.ReadConfig("config.json", &appConfig)
if err != nil {
log.Fatalf("Error loading config.json file. \"%s\"", err)
}
log.Printf("Application configuratrion loaded from config.json")

}

func setupWebServer() {

// Init HTTP Router - mux
router := mux.NewRouter()

Expand Down Expand Up @@ -95,7 +93,6 @@ func setupWebServer() {
}

log.Fatal(srv.ListenAndServe())

}

func CacheControlWrapper(h http.Handler) http.Handler {
Expand Down