Skip to content
Snippets Groups Projects
Verified Commit 70dac76a authored by Sheogorath's avatar Sheogorath :european_castle:
Browse files

Refactor image to centralize all redirects

This patch refactors the entire setup of the image. It combines various
redirect configs from images for CodiMD/Hedgedoc and puts them into a
single, universal image that can be deployed for all wanted domains.
parent 9fd088da
No related branches found
No related tags found
No related merge requests found
Pipeline #4549 passed
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
FROM nginx:alpine
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
COPY ./nginx.d/*.conf /etc/nginx/conf.d/
EXPOSE 80/tcp
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
```
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;
}
server {
listen *:80;
return 302 https://hedgedoc.org$request_uri;
}
server {
listen *:80;
server_name demo.codimd.org demo.hedgedoc.org;
return 301 https://demo.hedgedoc.org$request_uri;
}
server {
listen *:80;
server_name git.codimd.org git.hedgedoc.org;
return 302 https://github.com/hedgedoc/hedgedoc;
}
server {
listen *:80;
server_name social.codimd.org social.hedgedoc.org;
return 302 https://social.snopyta.org/@CodiMD;
}
server {
listen *:80;
server_name translate.codimd.org translate.hedgedoc.org;
return 302 https://poeditor.com/join/project/1OpGjF2Jir;
}
server {
listen *:80;
server_name community.codimd.org community.hedgedoc.org;
return 302 https://community.codimd.org$request_uri;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment