diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..974e88b --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,38 @@ +name: Docker Image CI + +on: + release: + types: [published] + +env: + IMAGE_NAME: "ghcr.io/codemicro/circuitbodge" + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Get tag version + id: get_version + run: echo "::set-output name=VERSION::$(echo ${GITHUB_REF/refs\/tags\//} | sed "s/^v//")" + + - name: Make image tags + id: make_tags + run: | + echo "::set-output name=LATEST::$IMAGE_NAME:latest" + echo "::set-output name=VERSIONED::$IMAGE_NAME:${{ steps.get_version.outputs.VERSION }}" + - name: Set version number + run: bash setVersionNumber.sh "${{ steps.get_version.outputs.VERSION }}" + + - name: Build Docker image + run: docker build . --file Dockerfile --tag ${{ steps.make_tags.outputs.LATEST }} --tag ${{ steps.make_tags.outputs.VERSIONED }} + + - name: Login to ghcr.io + run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io --username codemicro --password-stdin + + - name: Push image + run: docker push --all-tags $IMAGE_NAME \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4f8931a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.11-alpine + +ENV PIP_DISABLE_PIP_VERSION_CHECK=on + +RUN pip install poetry + +WORKDIR /usr/src/app + +COPY poetry.lock pyproject.toml ./ + +RUN poetry config virtualenvs.create false +RUN poetry install --no-interaction + +COPY ./circuit-laundry-notifier ./circuit-laundry-notifier + +ENV PYTHONPATH=circuit-laundry-notifier/ + +CMD ["poetry", "run", "gunicorn", "-b", "0.0.0.0:80", "-w", "1", "circuit-laundry-notifier.web:new()"] \ No newline at end of file diff --git a/circuit-laundry-notifier/web.py b/circuit-laundry-notifier/web.py index 9e2f86c..34b8f7d 100644 --- a/circuit-laundry-notifier/web.py +++ b/circuit-laundry-notifier/web.py @@ -16,7 +16,7 @@ from circuit_scraper import ( ) -def new(debug=False) -> flask.Flask: +def new(debug=True) -> flask.Flask: app = flask.Flask(__name__) app.add_url_rule("/", view_func=_web_get_index, methods=["GET"])