diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c1d6dcc --- /dev/null +++ b/Makefile @@ -0,0 +1,40 @@ +PROJECT = go-pb-jubilee + +VERSION=`git describe --tags` +BUILD=`date +%FT%T%z` + + +ECR_REPO = git.caliban.io/martin + +APP_IMAGE = $(ECR_REPO)/$(PROJECT):$(VERSION) + +NO_CACHE = true + +LDFLAGS=-ldflags "-w -s -X main.Version=${VERSION} -X main.Build=${BUILD}" + + +.PHONY: build +build: + #CC=/usr/local/musl/bin/musl-gcc go build --ldflags '-linkmode external -extldflags "-static"' server.go + GCO_ENABLED=0 GOOS=linux go build ${LDFLAGS} -o ${PROJECT} main.go + # go build ${LDFLAGS} -o ${PROJECT} server.go + +# docker build ./docker/. -t $(APP_IMAGE) --build-arg VERSION=$(VERSION) --no-cache=$(NO_CACHE) --compress=true + docker build --platform linux/amd64 --no-cache -force-rm --tag ${APP_IMAGE} --file ./docker/Dockerfile . + + +#push docker image to registry +.PHONY: push +push: build + docker push $(APP_IMAGE) + + +#push docker image to registry +.PHONY: run +run: build + docker run $(APP_IMAGE) + +ver: + @echo '$(VERSION)' + #echo $ERSION +.PHONY: ver \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e3f952f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: '3.5' + +services: + trainserver: + container_name: jubilee + image: git.caliban.io/martin/go-pb-jubilee:1.0.0 + restart: always + ports: + - "8090:8090" diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..8a37569 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,30 @@ +FROM debian:12-slim +# FROM alpine:latest + +WORKDIR /app + +RUN mkdir -p /app/dist + +COPY ./go-pb-jubilee ./docker/start.sh /app/ + +COPY ./pb_data /app/pb_data +COPY ./pb_public /app/pb_public + +RUN apt-get update && apt-get install -y ca-certificates + +# Need the following to get a go app to run inside a docker container +# as per: https://www.fairlyusefulcode.co.uk/post/go-alpine-linux/ -- DEAD!!! +# RUN apk upgrade musl +# RUN apk add gcompat + +# RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 +# RUN ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 + +RUN chmod +x /app/go-pb-jubilee +RUN chmod +x /app/start.sh + +EXPOSE 8090 + +CMD [ "/app/go-pb-jubilee", "serve", "--http=0.0.0.0:8090"] +# CMD [ "/app/start.sh"] + diff --git a/docker/start.sh b/docker/start.sh new file mode 100644 index 0000000..13bd36e --- /dev/null +++ b/docker/start.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -ex + +# npm run dev + +# npm run start + + +while true; do sleep infinity; done \ No newline at end of file diff --git a/go-pb-jubilee b/go-pb-jubilee new file mode 100755 index 0000000..78923da Binary files /dev/null and b/go-pb-jubilee differ