diff --git a/.gitea/workflows/build dev.yaml b/.gitea/workflows/build dev.yaml index a402e14..1ab0ca0 100644 --- a/.gitea/workflows/build dev.yaml +++ b/.gitea/workflows/build dev.yaml @@ -30,6 +30,31 @@ jobs: - name: Push image run: | docker push git.sh-edraft.de/sh-edraft.de/open-redirect-api-dev:$(cat version.txt) + + build-redirector: + runs-on: [runner] + container: git.sh-edraft.de/sh-edraft.de/act-runner:latest + steps: + - name: Clone Repository + uses: https://github.com/actions/checkout@v3 + with: + token: ${{ secrets.CI_ACCESS_TOKEN }} + + - name: Build docker + run: | + cd api + docker build -f dockerfile_redirector -t git.sh-edraft.de/sh-edraft.de/open-redirect-redirector-dev:$(cat ../version.txt) . + + - name: Login to registry git.sh-edraft.de + uses: https://github.com/docker/login-action@v1 + with: + registry: git.sh-edraft.de + username: ${{ secrets.CI_USERNAME }} + password: ${{ secrets.CI_ACCESS_TOKEN }} + + - name: Push image + run: | + docker push git.sh-edraft.de/sh-edraft.de/open-redirect-redirector-dev:$(cat version.txt) build-web: runs-on: [runner] @@ -53,7 +78,7 @@ jobs: - name: Build docker run: | cd web - docker build -t git.sh-edraft.de/sh-edraft.de/open-redirect-web:$(cat ../version.txt) . + docker build -t git.sh-edraft.de/sh-edraft.de/open-redirect-web-dev:$(cat ../version.txt) . - name: Login to registry git.sh-edraft.de uses: https://github.com/docker/login-action@v1 @@ -64,4 +89,4 @@ jobs: - name: Push image run: | - docker push git.sh-edraft.de/sh-edraft.de/open-redirect-web:$(cat version.txt) + docker push git.sh-edraft.de/sh-edraft.de/open-redirect-web-dev:$(cat version.txt) diff --git a/api/dockerfile b/api/dockerfile index 8d90931..8e913ce 100644 --- a/api/dockerfile +++ b/api/dockerfile @@ -3,6 +3,12 @@ FROM python:3.12.8-alpine WORKDIR /app COPY ./src/ . + +RUN rm redirector +RUN rm redirector.py +RUN rm -r static +RUN rm -r templates + COPY ./requirements.txt . RUN python -m pip install --upgrade pip diff --git a/api/dockerfile_redirector b/api/dockerfile_redirector new file mode 100644 index 0000000..5c37182 --- /dev/null +++ b/api/dockerfile_redirector @@ -0,0 +1,20 @@ +# syntax=docker/dockerfile:1 +FROM python:3.12.8-alpine + +WORKDIR /app + +COPY ./src/core . +COPY ./src/data . +COPY ./src/redirector.py . +COPY ./src/redirector . + +COPY ./requirements.txt . + +RUN python -m pip install --upgrade pip +RUN python -m pip install -r requirements.txt + +RUN apk update +RUN apk add bash +RUN apk add nano + +CMD [ "bash", "/app/redirector"] diff --git a/api/src/redirector b/api/src/redirector new file mode 100755 index 0000000..a67f673 --- /dev/null +++ b/api/src/redirector @@ -0,0 +1,16 @@ +#!/bin/bash + +if [[ $1 == "-dev" ]]; then + export ENVIRONMENT=development + export NAME=Open-redirect-dev +elif [[ $1 == "-stage" ]]; then + export ENVIRONMENT=staging + export NAME=Open-redirect-test +elif [[ $1 == "-prod" ]]; then + export ENVIRONMENT=production + export NAME=Open-redirect +fi + +export PYTHONPATH=./:$PYTHONPATH + +python3.12 redirector.py