diff options
author | Julien Dessaux | 2024-09-20 15:51:08 +0200 |
---|---|---|
committer | Julien Dessaux | 2024-09-20 22:32:04 +0200 |
commit | 6692a6abd487e53dc39e221b6a9387fd05e1fc89 (patch) | |
tree | a1f3b640a9038bc7d1717e1ea0a1372a400f7c57 | |
parent | chore(tooling): add makefile and fixed go module path (diff) | |
download | ods-6692a6abd487e53dc39e221b6a9387fd05e1fc89.tar.gz ods-6692a6abd487e53dc39e221b6a9387fd05e1fc89.tar.bz2 ods-6692a6abd487e53dc39e221b6a9387fd05e1fc89.zip |
chore(tooling): add a Dockerfile along with some makefile container targets
-rw-r--r-- | Dockerfile | 21 | ||||
-rw-r--r-- | GNUmakefile | 26 |
2 files changed, 45 insertions, 2 deletions
diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0cf3598 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +##### Build #################################################################### +FROM docker.io/library/golang:1.23-alpine + +WORKDIR /usr/src/app + +COPY go.mod go.sum ./ +RUN go mod download && go mod verify + +COPY . . +RUN CGO_ENABLED=0 go build ./... + +##### Run ###################################################################### +FROM alpine:3.20 + +ENV LANG en_US.utf8 + +RUN apk upgrade --no-cache + +COPY --from=0 /usr/src/app/ods /usr/local/bin/ + +ENTRYPOINT ["/usr/local/bin/ods"] diff --git a/GNUmakefile b/GNUmakefile index dd1979d..7b7c475 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -41,16 +41,38 @@ tidy: ## tidy up the code build: ## build the code CGO_ENABLED=0 go build -o $(OUTDIR)/ods ./ +.PHONY: clean +clean: ## clean the code + rm -f $(OUTDIR)/ods + .PHONY: run run: ## run the code go run ./ +##### Containers ############################################################### +.PHONY: container-build +container-build: ## build the container image + podman build \ + -t $(CONTAINER_REGISTRY)/ods:$(CONTAINER_TAG) \ + . + +.PHONY: container-push +container-push: ## push the container image to the container registry + podman push \ + $(CONTAINER_REGISTRY)/ods:$(CONTAINER_TAG) + +.PHONY: container-run +container-run: ## run the code inside podman + podman run --rm -ti \ + -p 8090:8090 \ + $(CONTAINER_REGISTRY)/ods:$(CONTAINER_TAG) + ##### Operations ############################################################### .PHONY: push push: tidy no-dirty check ## push changes to git remote git push git master .PHONY: deploy -deploy: check build ## deploy changes to the production server - rsync -a --delete $(OUTDIR)/ods root@ods.adyxax.org:/srv/ods/ +deploy: ## deploy changes to the production server + rsync $(OUTDIR)/ods root@ods.adyxax.org:/srv/ods/ ssh root@ods.adyxax.org "systemctl restart ods" |