From 96db44ce34705c1b4d82378cd8a0283029844933 Mon Sep 17 00:00:00 2001 From: Michal Kunc Date: Sun, 13 Feb 2022 16:26:40 +0100 Subject: [PATCH 1/5] Tweak Dockerfile - Don't use git, copy local copy. - Define volume as early as possible. --- Dockerfile | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index c37ce2f..f231b25 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,17 @@ FROM alpine:3.15.0 -RUN apk add --no-cache git go && \ - mkdir /oko-server && \ - cd /oko-server && \ - git clone https://github.com/Cernobor/oko-server.git /oko-server/git && \ +VOLUME ["/data"] +COPY . /oko-server/git + +RUN apk add --no-cache go && \ cd /oko-server/git && \ go build && \ cp /oko-server/git/oko-server /oko-server/ && \ cd /oko-server && \ rm -rf /oko-server/git && \ - mkdir /data && \ - apk del git go && \ + apk del go && \ rm -rf /root/go && \ echo -e '#!/bin/sh\n/oko-server/oko-server "$@"' > /oko-server/entrypoint.sh && \ chmod +x /oko-server/entrypoint.sh -VOLUME ["/data"] -ENTRYPOINT ["/oko-server/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/oko-server/entrypoint.sh"] From 7e2446438707d218f30f65ecaaf420e80f79d1fd Mon Sep 17 00:00:00 2001 From: Michal Kunc Date: Sun, 13 Feb 2022 16:38:58 +0100 Subject: [PATCH 2/5] Split Dockerfile into build & run images --- Dockerfile | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index f231b25..81a538e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,19 @@ -FROM alpine:3.15.0 +FROM alpine:3.15.0 AS build VOLUME ["/data"] COPY . /oko-server/git RUN apk add --no-cache go && \ cd /oko-server/git && \ - go build && \ - cp /oko-server/git/oko-server /oko-server/ && \ - cd /oko-server && \ - rm -rf /oko-server/git && \ - apk del go && \ - rm -rf /root/go && \ - echo -e '#!/bin/sh\n/oko-server/oko-server "$@"' > /oko-server/entrypoint.sh && \ + go build + +FROM alpine:3.15.0 +WORKDIR /oko-server +VOLUME [ "/data" ] + +RUN echo -e '#!/bin/sh\n/oko-server/oko-server "$@"' > /oko-server/entrypoint.sh && \ chmod +x /oko-server/entrypoint.sh +COPY --from=build /oko-server/git/oko-server/ /oko-server/ ENTRYPOINT ["/oko-server/entrypoint.sh"] + From 75f5300db3db6d25ac5d4512970c9fe5a1570c7d Mon Sep 17 00:00:00 2001 From: Michal Kunc Date: Sun, 13 Feb 2022 17:06:51 +0100 Subject: [PATCH 3/5] Add Dockerignore --- .dockerignore | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..16380d1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,41 @@ +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work + +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +# Project-specific +oko-server +*.sqlite* +.vscode +.git From 88fa84790d54874ed077b2f9a315f970defe4638 Mon Sep 17 00:00:00 2001 From: Michal Kunc Date: Sun, 13 Feb 2022 17:08:53 +0100 Subject: [PATCH 4/5] Add CI configs --- .drone.yml | 20 ++++++++++++++++++++ captain-definition | 4 ++++ 2 files changed, 24 insertions(+) create mode 100644 .drone.yml create mode 100644 captain-definition diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..29781e2 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,20 @@ +kind: pipeline +type: docker +name: default + +steps: +- name: deploy + image: caprover/cli-caprover:2.2.3 + commands: + - caprover deploy + environment: + CAPROVER_URL: + from_secret: caprover_url + CAPROVER_APP: + from_secret: caprover_app + CAPROVER_APP_TOKEN: + from_secret: app_token + CAPROVER_BRANCH: master + when: + branch: + - master diff --git a/captain-definition b/captain-definition new file mode 100644 index 0000000..17db556 --- /dev/null +++ b/captain-definition @@ -0,0 +1,4 @@ + { + "schemaVersion": 2, + "dockerfilePath": "./Dockerfile" + } From 4f2b0a3e117818a402749adfa20c3ffadda2f021 Mon Sep 17 00:00:00 2001 From: Michal Kunc Date: Sun, 13 Feb 2022 17:17:52 +0100 Subject: [PATCH 5/5] CI: master -> main branch --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 29781e2..de2d078 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,7 +14,7 @@ steps: from_secret: caprover_app CAPROVER_APP_TOKEN: from_secret: app_token - CAPROVER_BRANCH: master + CAPROVER_BRANCH: main when: branch: - - master + - main