Compare commits
11 Commits
e7387be995
...
v1.0
Author | SHA1 | Date | |
---|---|---|---|
5a0da6560d
|
|||
6aed7cb7fa
|
|||
5ed16bdab3
|
|||
7939a6fde1
|
|||
e78d0a7276
|
|||
e544ea8426
|
|||
56adeaf1b8
|
|||
a72eead432
|
|||
6e0375c666
|
|||
ff2a90ed3d
|
|||
6d92358f79
|
35
.gitea/workflows/image-build.yaml
Normal file
35
.gitea/workflows/image-build.yaml
Normal file
@ -0,0 +1,35 @@
|
||||
name: Build and Push Docker Image on Tag
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build and Push Docker Image
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: code.dlmw.ch
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: code.dlmw.ch/dlmw/qv:${{ env.GITHUB_REF_NAME }}
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -30,3 +30,4 @@ go.work.sum
|
||||
|
||||
# exclude built binary
|
||||
web
|
||||
dist/
|
||||
|
43
.goreleaser.yaml
Normal file
43
.goreleaser.yaml
Normal file
@ -0,0 +1,43 @@
|
||||
version: 2
|
||||
|
||||
before:
|
||||
hooks:
|
||||
- go mod tidy
|
||||
|
||||
builds:
|
||||
- id: qv
|
||||
main: ./cmd/web
|
||||
binary: qv
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- linux
|
||||
- windows
|
||||
- darwin
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
goamd64:
|
||||
- v1
|
||||
- v2
|
||||
- v3
|
||||
- v4
|
||||
goarm64:
|
||||
- v8.0
|
||||
ldflags:
|
||||
- -s -w
|
||||
|
||||
archives:
|
||||
- id: qv-archive
|
||||
name_template: >-
|
||||
{{ .ProjectName }}_
|
||||
{{- .Version }}_
|
||||
{{- .Os }}_
|
||||
{{- .Arch }}_
|
||||
{{- if eq .Arch "amd64" }}{{ .Amd64 }}
|
||||
{{- else if eq .Arch "arm64" }}{{ .Arm64 }}
|
||||
{{- end }}
|
||||
formats: [ "tar.gz" ]
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
formats: [ "zip" ]
|
15
Dockerfile
15
Dockerfile
@ -1,7 +1,4 @@
|
||||
FROM golang:1.23-alpine
|
||||
|
||||
RUN mkdir /qv
|
||||
ENV QV_DATABASE_PATH="/qv/qv.sqlite"
|
||||
FROM golang:1.23-alpine AS build
|
||||
|
||||
WORKDIR /usr/src/qv
|
||||
|
||||
@ -11,4 +8,12 @@ RUN go mod download && go mod verify
|
||||
COPY . .
|
||||
RUN go build -ldflags "-s -w" -v -o /usr/local/bin/qv ./cmd/web/
|
||||
|
||||
CMD ["qv"]
|
||||
FROM alpine
|
||||
|
||||
RUN mkdir /qv
|
||||
ENV QV_DATABASE_PATH="/qv/qv.sqlite"
|
||||
VOLUME /qv
|
||||
|
||||
COPY --from=build /usr/local/bin/qv /usr/local/bin/
|
||||
|
||||
ENTRYPOINT ["qv"]
|
20
Makefile
20
Makefile
@ -1,18 +1,10 @@
|
||||
BINARY_NAME=qv
|
||||
LD_FLAGS=-s -w
|
||||
PLATFORMS=linux/amd64 darwin/amd64 windows/amd64
|
||||
|
||||
.PHONY: compile clean
|
||||
.PHONY: compile compile-snapshot clean
|
||||
|
||||
compile:
|
||||
@for PLATFORM in $(PLATFORMS); do \
|
||||
GOOS=$$(echo $$PLATFORM | cut -d'/' -f1); \
|
||||
GOARCH=$$(echo $$PLATFORM | cut -d'/' -f2); \
|
||||
echo "Building for $$GOOS/$$GOARCH..."; \
|
||||
go build -ldflags="$(LD_FLAGS)" -o "$(BINARY_NAME)-$$GOOS-$$GOARCH" ./cmd/web/ && \
|
||||
echo "Build successful: $(BINARY_NAME)-$$GOOS-$$GOARCH" || \
|
||||
echo "Build failed for $$GOOS/$$GOARCH"; \
|
||||
done
|
||||
@goreleaser release --clean --skip=publish
|
||||
|
||||
compile-snapshot:
|
||||
@goreleaser release --clean --snapshot --skip=publish
|
||||
|
||||
clean:
|
||||
@rm qv-*-amd64
|
||||
@rm -r dist/
|
@ -3,7 +3,7 @@ info:
|
||||
title: qv - dlmw
|
||||
description: |-
|
||||
This is the documentation for the qv (Quadratic Voting) API.
|
||||
termsOfService: http://swagger.io/terms/
|
||||
termsOfService:
|
||||
contact:
|
||||
email: dylan@dlmw.ch
|
||||
license:
|
||||
@ -11,10 +11,10 @@ info:
|
||||
url: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
version: 0.0.1
|
||||
externalDocs:
|
||||
description: Find out more about qv # todo
|
||||
url: http://swagger.io # todo
|
||||
description: Get the code
|
||||
url: https://code.dlmw.ch/dlmw/qv
|
||||
servers:
|
||||
- url: https://petstore3.swagger.io/api/v3 # todo
|
||||
- url: https://qv.dlmw.ch/api
|
||||
tags:
|
||||
- name: election
|
||||
description: Retrieve data related to elections
|
||||
|
@ -98,7 +98,15 @@
|
||||
:href="`/election/${createdElectionId}`"
|
||||
class="text-blue-600 underline hover:text-blue-800"
|
||||
target="_blank">
|
||||
View Election
|
||||
View election
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<a
|
||||
:href="`/election/${createdElectionId}/results`"
|
||||
class="text-blue-600 underline hover:text-blue-800"
|
||||
target="_blank">
|
||||
View results
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user