From f30b6c5e9514514386f0842c5dc1b4ef9cb536f0 Mon Sep 17 00:00:00 2001 From: Jonas Zohren <git-pbkyr@jzohren.de> Date: Mon, 13 Feb 2023 00:53:47 +0100 Subject: [PATCH] chore: Update to oh14.dev deployment --- .dockerignore | 4 ++++ .gitlab-ci.yml | 46 ++++++++++++++++++++++++++++++++++++++- Dockerfile | 12 ++++++++++ captain-definition | 4 ++++ src/routes/+layout.svelte | 6 ++--- 5 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 captain-definition diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b236c5b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +/node_modules/ +/public/build/ +.DS_Store +test-results.xml \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bf978d0..3530562 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,5 @@ pages: + needs: [] image: node:18 script: - "corepack enable" # Add pnpm, see https://nodejs.org/api/corepack.html @@ -6,4 +7,47 @@ pages: - "pnpm run build" artifacts: paths: - - "public" \ No newline at end of file + - "public" + rules: + - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + +build_docker_main: + needs: [] + image: + name: "gcr.io/kaniko-project/executor:debug" + entrypoint: [ "" ] + script: + - "mkdir -p /kaniko/.docker" + - 'echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json' + - "/kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:commit-$CI_COMMIT_SHORT_SHA --destination $CI_REGISTRY_IMAGE:latest" + rules: + - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + +build_docker_branches: + needs: [] + image: + name: "gcr.io/kaniko-project/executor:debug" + entrypoint: [ "" ] + script: + - "mkdir -p /kaniko/.docker" + - 'echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json' + - "/kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:commit-$CI_COMMIT_SHORT_SHA --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-latest" + rules: + - if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH' + +deploy_to_caprover: + needs: + - "build_docker_main" + image: + name: "caprover/cli-caprover:latest" + entrypoint: [ "" ] + variables: + # We don't need the files, just tell CapRover to use the built docker image: + GIT_STRATEGY: none + script: + - "caprover deploy -h https://captain.$CAPROVER_URL -a $CAPROVER_APP --imageName $CI_REGISTRY_IMAGE:commit-$CI_COMMIT_SHORT_SHA" + environment: + name: "production" + url: "https://ra-tools.oh14.dev/" + rules: + - if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CAPROVER_URL && $CAPROVER_APP_TOKEN && $CAPROVER_APP" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fb2328f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM node:18-alpine AS build +RUN corepack enable + +WORKDIR /build +COPY package.json pnpm-lock.yaml /build/ +RUN pnpm install --ignore-scripts + +COPY . . +RUN pnpm run build + +FROM pierrezemb/gostatic AS final +COPY --from=build /build/public/ /srv/http/ \ No newline at end of file diff --git a/captain-definition b/captain-definition new file mode 100644 index 0000000..3c53bed --- /dev/null +++ b/captain-definition @@ -0,0 +1,4 @@ +{ + "schemaVersion" :2 , + "dockerfilePath" : "Dockerfile" + } \ No newline at end of file diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 0b71528..bfc7eb7 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -2,8 +2,8 @@ <hr style="margin-top: 2rem;" /> <a href="./">Home</a> – -<a href="https://gitlab.fachschaften.org/jfowl/ra-tools/">Source Code (MIT licensed)</a> +<a href="https://gitlab.fachschaften.org/oh14-dev/ra-tools/">Source Code (MIT licensed)</a> – -<a href="https://oh14.de/impressum">Imprint</a> +<a href="https://oh14.dev/impressum">Imprint</a> – -<a href="https://oh14.de/datenschutzerklaerung.html">Data Privacy Statement</a> +<a href="https://oh14.dev/datenschutz.html">Data Privacy Statement</a> -- GitLab