diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..ebc17d1b --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,51 @@ +name: Docker + +on: + push: + branches: [ master ] + tags: [ '*' ] + workflow_dispatch: + + +jobs: + push: + if: github.repository == 'rq/rq' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Push + run: | + # Parse Version + # "master" -> "master" + # "v1.2.3" -> "1.2.3", "1.2", "1", "latest" + + VERSIONS=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + + [[ "${{ github.ref }}" == "refs/tags/"* ]] && { + VERSIONS=$(echo $VERSIONS | sed -e 's/^v//') + i="$VERSIONS" + while [[ "$i" == *"."* ]] + do i="$(echo "$i" | sed 's/\(.*\)\..*/\1/g')" + VERSIONS="$VERSIONS $i" + done + VERSIONS="$VERSIONS latest" + } + + echo Building with tags: $VERSIONS + + # Login to registries + echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin + echo "${{ secrets.DOCKER_TOKEN }}" | docker login -u TODO --password-stdin + + # Build image + docker build . --tag worker + + # Tag and Push + for VERSION in $VERSIONS + do docker tag worker redisqueue/worker:$VERSION + docker push redisqueue/worker:$VERSION + docker tag worker docker.pkg.github.com/rq/rq/worker:$VERSION + docker push docker.pkg.github.com/rq/rq/worker:$VERSION + done diff --git a/Dockerfile b/Dockerfile index 6cd1f184..231549de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,11 @@ -FROM ubuntu:latest +FROM python:3.8 -RUN apt-get update \ - && apt-get install -y \ - redis-server \ - python3-pip \ - stunnel - -COPY tests/ssl_config/private.pem tests/ssl_config/stunnel.conf /etc/stunnel/ +WORKDIR /root COPY . /tmp/rq -WORKDIR /tmp/rq -RUN pip3 install -r /tmp/rq/requirements.txt -r /tmp/rq/dev-requirements.txt \ - && python3 /tmp/rq/setup.py build \ - && python3 /tmp/rq/setup.py install -CMD stunnel \ - & redis-server \ - & RUN_SLOW_TESTS_TOO=1 RUN_SSL_TESTS=1 pytest /tmp/rq/tests/ --durations=5 -v --log-cli-level 10 +RUN pip install /tmp/rq + +RUN rm -r /tmp/rq + +ENTRYPOINT ["rq", "worker"] diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 82ddd507..00000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM python:3.8 - -RUN pip install rq - -ENTRYPOINT ["rq", "worker"] diff --git a/run_tests_in_docker.sh b/run_tests_in_docker.sh index 30cae19c..770957fe 100755 --- a/run_tests_in_docker.sh +++ b/run_tests_in_docker.sh @@ -1,3 +1,3 @@ #!/bin/bash -docker build . -t rqtest && docker run -it --rm rqtest +docker build -f tests/Dockerfile . -t rqtest && docker run -it --rm rqtest diff --git a/tests/Dockerfile b/tests/Dockerfile new file mode 100644 index 00000000..6cd1f184 --- /dev/null +++ b/tests/Dockerfile @@ -0,0 +1,19 @@ +FROM ubuntu:latest + +RUN apt-get update \ + && apt-get install -y \ + redis-server \ + python3-pip \ + stunnel + +COPY tests/ssl_config/private.pem tests/ssl_config/stunnel.conf /etc/stunnel/ + +COPY . /tmp/rq +WORKDIR /tmp/rq +RUN pip3 install -r /tmp/rq/requirements.txt -r /tmp/rq/dev-requirements.txt \ + && python3 /tmp/rq/setup.py build \ + && python3 /tmp/rq/setup.py install + +CMD stunnel \ + & redis-server \ + & RUN_SLOW_TESTS_TOO=1 RUN_SSL_TESTS=1 pytest /tmp/rq/tests/ --durations=5 -v --log-cli-level 10