diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1431b64bbf9346f972e52dad96203004265c15b9..6fce83f5a850f115c2ec371e298911cbc29be6a0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,21 +1,58 @@ -image: quay.io/sheogorath/build-ah-engine +include: + - project: 'container-library/build-ah-engine' + ref: 1.3.1 + file: '/gitlab-ci-template.yml' -before_script: - - podman login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY +stages: + - build + - test + - tag + - deploy -build-master: - stage: build +nginx-validation: + stage: test + image: quay.io/sheogorath/build-ah-engine:latest + variables: + LANG: C.UTF-8 + before_script: + - dnf install -y curl script: - - podman build --pull -t "$CI_REGISTRY_IMAGE" . - - podman push "$CI_REGISTRY_IMAGE" "docker://$CI_REGISTRY_IMAGE" - only: - - master + - podman run -d -p 80:80 --name testing $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA + - sleep 5 + # Validate config + - podman exec testing nginx -c /etc/nginx/nginx.conf -t + # Test default + - "curl -v -H 'Host: example.org' http://localhost/ 2>&1 | grep -q 'https://hedgedoc.org'" + # Test main domain + - "curl -v -H 'Host: codimd.org' http://localhost/ 2>&1 | grep -q 'https://hedgedoc.org'" + - "curl -v -H 'Host: hedgedoc.org' http://localhost/ 2>&1 | grep -q 'https://hedgedoc.org'" + # Test demo + - "curl -v -H 'Host: demo.codimd.org' http://localhost/ 2>&1 | grep -q 'https://demo.hedgedoc.org'" + - "curl -v -H 'Host: demo.hedgedoc.org' http://localhost/ 2>&1 | grep -q 'https://demo.hedgedoc.org'" + # Test social + - "curl -v -H 'Host: social.codimd.org' http://localhost/ 2>&1 | grep -q 'https://social.snopyta.org/@CodiMD'" + - "curl -v -H 'Host: social.hedgedoc.org' http://localhost/ 2>&1 | grep -q 'https://social.snopyta.org/@CodiMD'" + # Test community + - "curl -v -H 'Host: community.codimd.org' http://localhost/ 2>&1 | grep -q 'https://community.codimd.org'" + - "curl -v -H 'Host: community.hedgedoc.org' http://localhost/ 2>&1 | grep -q 'https://community.codimd.org'" + # Test translate + - "curl -v -H 'Host: translate.codimd.org' http://localhost/ 2>&1 | grep -q 'https://poeditor.com/join/project/1OpGjF2Jir'" + - "curl -v -H 'Host: translate.hedgedoc.org' http://localhost/ 2>&1 | grep -q 'https://poeditor.com/join/project/1OpGjF2Jir'" + # Cleanup + - podman stop testing + - podman rm testing -build: - stage: build - script: - - podman build --pull -t "$CI_REGISTRY_IMAGE" . - - echo "Image will be pushed to ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}" - - podman push "$CI_REGISTRY_IMAGE" "docker://${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}" - except: - - master +container-tagging: + stage: tag + variables: + CI_REGISTRY_IMAGE_VERSION: latest + +deploy: + stage: deploy + variables: + PLAYBOOK: static_websites.yml + trigger: + project: shivering-isles/ansible-infrastructure-deploy + strategy: depend + rules: + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH diff --git a/Dockerfile b/Dockerfile index c10f6a4e9b734fa2834e8c80763b68715097143e..b7ca4a073e10b55a181a0f7935b21f95168768e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM nginx:alpine -COPY ./nginx.conf /etc/nginx/conf.d/default.conf +COPY ./nginx.d/*.conf /etc/nginx/conf.d/ EXPOSE 80/tcp diff --git a/README.md b/README.md index 70813144d67334dc961a3251babd0901869de371..3acf80bdd3ce37a406d27c6566c2baacc0f204fd 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -Translation redirect +HedgeDoc redirect === -CodiMD has currently no webpage. So let's redirect people to our GitHub page. +This project manages all redirects for the HedgeDoc project. How to build --- @@ -9,7 +9,7 @@ How to build Simply build the docker container ```console -git clone https://octo.sh/Sheogorath/codimd-redirect +git clone https://git.shivering-isles.com/codimd/redirect.git cd codimd-redirect docker build -t quay.io/sheogorath/codimd-redirect:latest . ``` @@ -28,4 +28,3 @@ Or run locally to check details: ```console docker run --rm -it -p 80:80 quay.io/sheogorath/codimd-redirect ``` - diff --git a/nginx.conf b/nginx.conf deleted file mode 100644 index 527d0e79a1d4bb47d871405de17f6e3b60523f9f..0000000000000000000000000000000000000000 --- a/nginx.conf +++ /dev/null @@ -1,6 +0,0 @@ -server { - #implemented by default, change if you need different ip or port - listen *:80; - server_name codimd.org www.codimd.org; - return 302 https://github.com/codimd/server; -} diff --git a/nginx.d/default.conf b/nginx.d/default.conf new file mode 100644 index 0000000000000000000000000000000000000000..167b0b6c2277e71fa42d59fb9d3f652630c8e7dc --- /dev/null +++ b/nginx.d/default.conf @@ -0,0 +1,4 @@ +server { + listen *:80; + return 302 https://hedgedoc.org$request_uri; +} diff --git a/nginx.d/demo.conf b/nginx.d/demo.conf new file mode 100644 index 0000000000000000000000000000000000000000..3ab598b15cc800d08e11c8a75cd0f73e72a2c6a5 --- /dev/null +++ b/nginx.d/demo.conf @@ -0,0 +1,5 @@ +server { + listen *:80; + server_name demo.codimd.org demo.hedgedoc.org; + return 301 https://demo.hedgedoc.org$request_uri; +} diff --git a/nginx.d/git.conf b/nginx.d/git.conf new file mode 100644 index 0000000000000000000000000000000000000000..eb24ef6ef4c32c67b0f25e085fb7c5b3eca91f59 --- /dev/null +++ b/nginx.d/git.conf @@ -0,0 +1,5 @@ +server { + listen *:80; + server_name git.codimd.org git.hedgedoc.org; + return 302 https://github.com/hedgedoc/hedgedoc; +} diff --git a/nginx.d/social.conf b/nginx.d/social.conf new file mode 100644 index 0000000000000000000000000000000000000000..e7ee3b73d17b31e4d7b6ca6dc4345771a39d6e14 --- /dev/null +++ b/nginx.d/social.conf @@ -0,0 +1,5 @@ +server { + listen *:80; + server_name social.codimd.org social.hedgedoc.org; + return 302 https://social.snopyta.org/@CodiMD; +} diff --git a/nginx.d/translate.conf b/nginx.d/translate.conf new file mode 100644 index 0000000000000000000000000000000000000000..6991ae42fc8be1ac1221d04950aa0781f6cd8ada --- /dev/null +++ b/nginx.d/translate.conf @@ -0,0 +1,5 @@ +server { + listen *:80; + server_name translate.codimd.org translate.hedgedoc.org; + return 302 https://poeditor.com/join/project/1OpGjF2Jir; +} diff --git a/nginx.d/zz_community.conf b/nginx.d/zz_community.conf new file mode 100644 index 0000000000000000000000000000000000000000..3cc2498248866e4a2c018dc4a273ca72431ec0ed --- /dev/null +++ b/nginx.d/zz_community.conf @@ -0,0 +1,5 @@ +server { + listen *:80; + server_name community.codimd.org community.hedgedoc.org; + return 302 https://community.codimd.org$request_uri; +}