Enable CGO, build and publish Dockerfile

This commit is contained in:
Piotr Rogowski 2022-11-09 21:14:38 +01:00
parent 73fc1c7c0a
commit 322886cdfe
No known key found for this signature in database
GPG Key ID: 4A842D702D9C6F8F
7 changed files with 64 additions and 19 deletions

32
.dockerignore Normal file
View File

@ -0,0 +1,32 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
# Go workspace file
go.work
# mac
.DS_Store
# pb_data and backups
/backup
/pb_data
/pb_data.zip
/pb_data.tar.gz
# build
cloud-backend
cloud-backend.exe
main

View File

@ -10,7 +10,7 @@ builds:
ldflags:
- -s -w -X github.com/hyper-tuner/cloud-backend.Version={{ .Version }}
env:
- CGO_ENABLED=0
- CGO_ENABLED=1
goos:
- linux
- windows

15
Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM golang:1.19 AS builder
RUN mkdir /app
COPY . /app
WORKDIR /app
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o cloud-backend
FROM alpine:latest AS production
COPY --from=builder /app .
EXPOSE 8090
CMD ["./cloud-backend", "serve", "--http=0.0.0.0:8090"]

View File

@ -21,12 +21,6 @@ This is the backend for the [HyperTuner Cloud](https://github.com/hyper-tuner/hy
- deployment scripts / **Docker** and docker compose files
- migration scripts and guides
## Upgrading
Some versions will contain breaking changes.
If you are upgrading from a previous version, please read the [UPGRADE.md](UPGRADE.md) file.
## Setting up your instance
Use provider Docker files from the `/docker` directory or just grab the binary from the [Releases](https://github.com/hyper-tuner/cloud-backend/releases) page.
@ -39,6 +33,20 @@ This will create `pb_data` directory where all the data will be stored (SQLite,
Now you can access the admin UI at: [https://your-instance.com/_/](https://your-instance.com/_/).
### Docker
https://hub.docker.com/r/karniv001/hyper-tuner-cloud-backend
```bash
docker pull karniv001/hyper-tuner-cloud-backend
```
## Upgrading
Some versions will contain breaking changes.
If you are upgrading from a previous version, please read the [UPGRADE.md](UPGRADE.md) file.
### Application name and URL
Located in admin UI: `Settings -> Application`.

View File

@ -2,11 +2,9 @@ version: '3.1'
services:
cloud-backend:
platform: linux/x86_64
build: .
image: karniv001/hyper-tuner-cloud-backend:latest
restart: unless-stopped
command: ["/cloud-backend", "serve", "--http=0.0.0.0:8080"]
volumes:
- ./pb_data:/pb_data
ports:
- 80:8080
- 80:8090

View File

@ -1 +0,0 @@
pb_data

View File

@ -1,7 +0,0 @@
FROM alpine:latest
ARG VERSION=1.1.1
ADD https://github.com/hyper-tuner/cloud-backend/releases/download/v${VERSION}/cloud-backend_${VERSION}_linux_amd64.tar.gz /tmp/cloud-backend
RUN tar -zxf /tmp/cloud-backend