diff --git a/.dockerignore b/.dockerignore index ff3aeff0..5e704b3c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -20,3 +20,11 @@ sql/ # READMEs *.md + +# other stuff +*.log +MANIFEST* +Dockerfile + +**/__pycache__/** +**/test/** diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 0103071f..4f95b5f2 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -10,6 +10,18 @@ jobs: docker_build: runs-on: ubuntu-latest + services: + mysql: + image: mysql:8.0.22 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + MYSQL_DATABASE: index_digest + MYSQL_USER: test + MYSQL_PASSWORD: p4ss + ports: + - "53306:3306" + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + steps: - uses: actions/checkout@v1 @@ -23,3 +35,13 @@ jobs: --cache-from macbre/index-digest:latest \ --tag ${{ github.repository }} docker images + docker ps + + - name: Check the version + run: | + docker run ${{ github.repository }} --version + + - name: Run the container and connect to the test database + run: | + docker run --network=host ${{ github.repository }} mysql://test:p4ss@0.0.0.0:53306/index_digest | tee /tmp/results + grep "Jolly, good! No issues to report" /tmp/results diff --git a/Dockerfile b/Dockerfile index 916ebb1a..255abd94 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # https://hub.docker.com/_/python/ -FROM python:3.9-slim-buster +FROM python:3.9-alpine WORKDIR /opt/macbre/index-digest @@ -9,10 +9,12 @@ ADD indexdigest/__init__.py ./indexdigest/__init__.py # installs mysql_config and pip dependencies # https://github.com/gliderlabs/docker-alpine/issues/181 -RUN apt-get update && apt-get install -y libmariadb-dev-compat gcc \ +RUN apk upgrade \ + && apk add --virtual build-deps gcc musl-dev \ + && apk add mariadb-dev \ && pip install indexdigest \ && rm -rf ~/.cache/pip \ - && apt-get remove -y gcc && apt-get autoremove -y + && apk del build-deps # install the remaining files ADD . .