diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..18ed876 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,24 @@ +name: Docker Image CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup Python + uses: actions/setup-python@v5.0.0 + with: + # Version range or exact version of Python or PyPy to use, using SemVer's version range syntax. Reads from .python-version if unset. + python-version: 3.11 + cache: pip + - name: Build the Docker image + run: docker build . --file Dockerfile --tag contacts:$(date +%s) diff --git a/Dockerfile b/Dockerfile index e378793..171b132 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,14 +4,14 @@ WORKDIR /app/web RUN apk update && \ apk add py-pillow build-base ca-certificates libffi-dev && \ rm -rf /var/cache/apk/* -RUN pip3 install --no-cache-dir --upgrade pip setuptools wheel +RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel ENV FLASK_APP=contacts SIM_CONTACTS_SETTINGS=config.py FLASK_DEBUG=0 # https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#add-or-copy # Try not to invalidate the `pip install` step by copything everything else after COPY requirements.txt /app/web/ -RUN pip3 install --no-cache-dir -r requirements.txt && mkdir -p /app/web/instance +RUN python3 -m pip install --no-cache-dir -r requirements.txt && mkdir -p /app/web/instance RUN rm /app/web/app.py COPY . /app/web/