From eeb48281e470198b4a3a6609deff4b3339145ed7 Mon Sep 17 00:00:00 2001 From: Settel Date: Sun, 6 Nov 2022 09:47:43 +0100 Subject: [PATCH] feat: refactor podman build --- .woodpecker.yml | 28 +++++++++++++++++-- podman/Dockerfile => Dockerfile | 2 +- Makefile | 23 +++++++++++---- {podman => build}/.gitignore | 0 .../3e6eef0e-3dbd-4f60-9009-1be052408d0a.json | 0 podman/Makefile | 23 --------------- server/Makefile | 3 -- 7 files changed, 44 insertions(+), 35 deletions(-) rename podman/Dockerfile => Dockerfile (69%) rename {podman => build}/.gitignore (100%) rename {podman => build}/files/data/users/3e6eef0e-3dbd-4f60-9009-1be052408d0a.json (100%) delete mode 100644 podman/Makefile diff --git a/.woodpecker.yml b/.woodpecker.yml index 098bac6..c4839c0 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -2,8 +2,8 @@ pipeline: frontend: image: node:16-alpine commands: - - ( cd client && yarn install ) - - ( cd client/ && yarn generate ) + # - ( cd client && yarn install ) + # - ( cd client/ && yarn generate ) - mkdir -p client/.output/public/ when: branch: woodpecker @@ -17,3 +17,27 @@ pipeline: - make -C server build when: branch: woodpecker + + build-publish: + image: mtvb/drone-kaniko + settings: + reproducible: true + username: + from_secret: docker.private.gnuher.de.username + password: + from_secret: docker.private.gnuher.de.password + repo: knowyt + registry: docker.private.gnuher.de + tags: latest + when: + branch: woodpecker + + notify: + image: plugins/matrix + settings: + homeserver: https://matrix.bw-messenger.de/ + roomid: wHCOKvEHLUmsNybNwh:matrix.bw-messenger.de + username: + from_secret: matrix.bw-messenger.de.username + password: + from_secret: matrix.bw-messenger.de.password diff --git a/podman/Dockerfile b/Dockerfile similarity index 69% rename from podman/Dockerfile rename to Dockerfile index 79fb427..8f74371 100644 --- a/podman/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM scratch EXPOSE 32039 -COPY files . +COPY build/files . CMD ["/knowyt"] diff --git a/Makefile b/Makefile index 56814b6..16e1d88 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ TMUX_SESSION=knowyt -VERSION=v$(shell grep version client/package.json | cut -d\" -f4) +VERSION=$(shell grep version client/package.json | cut -d\" -f4) .PHONY: info run-all run-server run-client run-tmux build podman clean @@ -7,7 +7,7 @@ info: @echo available targets: @perl -ne 'm/^([\w\-]+):/ && print(" $$1\n");' Makefile -setup +setup: @echo "I checking for tools" @for binary in go tmux node yarn npx podman; do \ echo -n " $$binary: " ; \ @@ -48,18 +48,29 @@ build: echo $(VERSION) (cd client/ && yarn generate) $(MAKE) -C server build - $(MAKE) -C podman build save VERSION="$(VERSION)" + $(MAKE) podman-build + $(MAKE) podman-save + +podman-build: + cp server/knowyt build/files/ + podman build --tag knowyt:$(VERSION) . + +podman-save: + rm -f build/knowyt-$(VERSION).tar + podman save knowyt:$(VERSION) -o build/knowyt-$(VERSION).tar + ls -lh build/knowyt-$(VERSION).tar podman-run: - $(MAKE) -C podman run + podman run --rm -it -p 32039:32039 -v $$(PWD)/server/data/:/data --name knowyt knowyt:$(VERSION) -run-standalone: - $(MAKE) -C server run-standalone +podman-stop: + podman stop knowyt clean: rm -rf client/.output/ rm -rf client/.nuxt/ $(MAKE) -C server clean + rm -f build/files/knowyt build/knowyt-*.tar reset-data: rm -rf server/data/ diff --git a/podman/.gitignore b/build/.gitignore similarity index 100% rename from podman/.gitignore rename to build/.gitignore diff --git a/podman/files/data/users/3e6eef0e-3dbd-4f60-9009-1be052408d0a.json b/build/files/data/users/3e6eef0e-3dbd-4f60-9009-1be052408d0a.json similarity index 100% rename from podman/files/data/users/3e6eef0e-3dbd-4f60-9009-1be052408d0a.json rename to build/files/data/users/3e6eef0e-3dbd-4f60-9009-1be052408d0a.json diff --git a/podman/Makefile b/podman/Makefile deleted file mode 100644 index 016bb79..0000000 --- a/podman/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -VERSION=latest - -info: - @echo available targets: - @perl -ne 'm/^([\w\-]+):/ && print(" $$1\n");' Makefile - -build: - cp ../server/knowyt files/ - podman build --tag knowyt:$(VERSION) . - -run: - podman run --rm -it -p 32039:32039 -v /home/settel/codes/go/knowyt/server/data/:/data --name knowyt knowyt:$(VERSION) - -stop: - podman stop knowyt - -save: - rm -f knowyt-$(VERSION).tar - podman save knowyt:$(VERSION) -o knowyt-$(VERSION).tar - cd .. && ls -lh podman/knowyt-$(VERSION).tar - -clean: - rm -f files/knowyt knowyt-$(VERSION).tar diff --git a/server/Makefile b/server/Makefile index 612ae94..9226084 100644 --- a/server/Makefile +++ b/server/Makefile @@ -20,9 +20,6 @@ run-loop: -r _run-inotify-restart \ -- $(MAKE) '$$TARGET' -run-standalone: - cd src/ && ../knowyt - _run-endless-loop: while true; do $(MAKE) run || sleep 3; done