Added docker support

This commit is contained in:
Borna Rajković 2024-01-03 21:03:06 +01:00
parent 937216bda6
commit 9b0723fb79
3 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,8 @@
version: '3.1'
services:
rem:
image: registry.bbr-dev.info/resource-manager/backend:latest-dev
restart: on-failure
ports:
- 5201:5201

19
dockerfile Normal file
View File

@ -0,0 +1,19 @@
### STAGE 1.a: Prepare certs ###
FROM alpine:latest as certs
RUN apk --update add ca-certificates
### STAGE 1.b: Build ###
FROM golang as go-build
WORKDIR /root
COPY go.mod go.sum ./
# install packages
RUN go mod download
COPY . .
ENV CGO_ENABLED=0
RUN go build -tags timetzdata resource_manager
### Stage 2: Run ###
FROM scratch
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=go-build /root/resource_manager /usr/bin/resource_manager
ENTRYPOINT ["resource_manager"]

33
makefile Normal file
View File

@ -0,0 +1,33 @@
# scripts for building account tracker backend
# requires go 1.18+ and git installed
VERSION := 0.0.1
serve:
go run ./...
setup:
go get
docker-dev:
docker image build -t registry.bbr-dev.info/resource-manager/backend:$(VERSION)-dev .
docker tag registry.bbr-dev.info/resource-manager/backend:$(VERSION)-dev registry.bbr-dev.info/resource-manager/backend:latest-dev
docker image push registry.bbr-dev.info/resource-manager/backend:$(VERSION)-dev
docker image push registry.bbr-dev.info/resource-manager/backend:latest-dev
docker-prod:
docker image build -t registry.bbr-dev.info/resource-manager/backend:$(VERSION) .
docker tag registry.bbr-dev.info/resource-manager/backend:$(VERSION) registry.bbr-dev.info/resource-manager/backend:latest
docker image push registry.bbr-dev.info/resource-manager/backend:$(VERSION)
docker image push registry.bbr-dev.info/resource-manager/backend:latest
release:
git tag $(VERSION)
git push origin $(VERSION)
test:
go test ./...
clean:
rm -rf resource-manager