This commit is contained in:
2023-03-14 19:48:22 +01:00
parent 3f91774a87
commit 0bd5587ce2
3 changed files with 61 additions and 0 deletions

41
docker/Dockerfile Normal file
View File

@@ -0,0 +1,41 @@
# syntax=docker/dockerfile:1 -*-python-*-
FROM golang:1.18-alpine
ARG VERSION
LABEL upd_version=0.1
ENV HOME="/" \
OS_ARCH="amd64" \
OS_FLAVOUR="alpine" \
OS_NAME="linux"
RUN echo $VERSION
RUN install -o 1001 -g 1001 -d /data
WORKDIR /build
RUN mkdir -p api cfg cmd
COPY upd/api/* ./api/
COPY upd/cfg/* ./cfg/
COPY upd/cmd/* ./cmd/
COPY upd/*.* ./
RUN go mod tidy
#RUN echo $VERSION
# doesn't work, see
# https://blog.alexellis.io/inject-build-time-vars-golang/
RUN go build -ldflags "-X upd/cfg.VERSION=$VERSION"
RUN echo $VERSION > version
RUN ls -l
WORKDIR /app
RUN cp /build/upd /app/upd
#RUN rm -rf /build
ENV UPD_LISTEN=:8080
ENV UPD_STORAGEDIR=/data
ENV UPD_DBFILE=/data/bbolt.db
ENV UPD_DEBUG=1
USER 1001:1001
EXPOSE 8080
VOLUME /data
CMD ["/app/upd"]

14
docker/Makefile Normal file
View File

@@ -0,0 +1,14 @@
upd = ../upd/upd
version = $(shell egrep "= .v" ../upd/cfg/config.go | cut -d'=' -f2 | cut -d'"' -f 2)
BRANCH = $(shell git branch --show-current)
COMMIT = $(shell git rev-parse --short=8 HEAD)
BUILD = $(shell date +%Y.%m.%d.%H%M%S)
VERSION := $(if $(filter $(BRANCH), development),$(version)-$(BRANCH)-$(COMMIT)-$(BUILD),$(version))
v:
@echo $(VERSION)
build:
cp -a ../updlocal upd
make -C upd clean
docker-compose build --build-arg VERSION=$(VERSION)

View File

@@ -0,0 +1,6 @@
version: "3.9"
services:
upd:
build: .
ports:
- "8080:8080"