Improve build system and Docker configuration

- Switch Dockerfile base image from golang:1.23-bookworm to debian:12-slim
- Update Dockerfile to use pre-built binary instead of building in container
- Fix Docker CMD to use new CLI flag format with --listen and --root-path
- Update Makefile to build binary to ./dist/ directory with CGO_ENABLED=0
- Make build-docker target depend on build target for efficiency
- Change clean target to remove ./dist directory instead of single binary
This commit is contained in:
2025-05-26 13:29:33 +03:00
parent 28008a320d
commit 7ea36d23dd
2 changed files with 8 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
FROM golang:1.23-bookworm FROM debian:12-slim
RUN apt-get update && apt-get upgrade -y RUN apt-get update && apt-get upgrade -y
@@ -9,7 +9,8 @@ COPY ./gemserve /app/gemserve
WORKDIR /app WORKDIR /app
RUN chmod +x /app/gemserve && \ RUN chmod +x /app/gemserve && \
chown -R user:user /app chown -R root:root /app && \
chmod -R 755 /app
USER user USER user
CMD ["/app/gemserve","0.0.0.0:1965"] CMD ["/app/gemserve","--listen","0.0.0.0:1965","--root-path","/srv"]

View File

@@ -4,7 +4,7 @@ export PATH := $(PATH)
all: fmt lintfix tidy test clean build all: fmt lintfix tidy test clean build
clean: clean:
rm -f ./gemserve rm -rf ./dist
debug: debug:
@echo "PATH: $(PATH)" @echo "PATH: $(PATH)"
@@ -35,9 +35,10 @@ lintfix: fmt
golangci-lint run --fix golangci-lint run --fix
build: build:
go build -o ./gemserve ./main.go mkdir -p ./dist
CGO_ENABLED=0 go build -o ./dist/gemserve ./main.go
build-docker: build-docker: build
docker build -t gemserve . docker build -t gemserve .
show-updates: show-updates: