From f6b522de56abd126d21ee52e93211ed1089a7e73 Mon Sep 17 00:00:00 2001 From: Andre Rademacher Date: Wed, 25 Oct 2023 12:12:01 +0200 Subject: [PATCH] 4 update python image --- .cache/pip/pip.conf | 2 -- Dockerfile | 30 +++++++++++++++++++ README.md | 6 ++-- .../build.sh => ci/build_docker_image.sh | 3 +- container.sh | 3 +- container/Dockerfile | 7 ----- .../{Instructions.md => README.md} | 0 kata/GetNthEvenNumber/test_NthEven.py | 2 +- .../{Instructions.md => README.md} | 0 kata/RemoveTheTime/test_Remove.py | 2 +- 10 files changed, 38 insertions(+), 17 deletions(-) delete mode 100644 .cache/pip/pip.conf create mode 100644 Dockerfile rename container/build.sh => ci/build_docker_image.sh (88%) delete mode 100644 container/Dockerfile rename kata/GetNthEvenNumber/{Instructions.md => README.md} (100%) rename kata/RemoveTheTime/{Instructions.md => README.md} (100%) diff --git a/.cache/pip/pip.conf b/.cache/pip/pip.conf deleted file mode 100644 index bfecb1d..0000000 --- a/.cache/pip/pip.conf +++ /dev/null @@ -1,2 +0,0 @@ -[global] -cache-dir=/.cache \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..14af36c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM python:3.11-bookworm +LABEL maintainer="andre.rademacher.business@googlemail.com" + +ARG GID=1000 +ARG UID=1000 +ARG UNAME=codewars + +ARG PIPCACHE="/.cache/pip" + +RUN groupadd \ + --gid ${GID} \ + --non-unique \ + ${UNAME} + +RUN useradd \ + --create-home \ + --gid ${GID} \ + --home-dir /home/codewars \ + --shell /bin/bash \ + --uid ${UID} \ + ${UNAME} + +RUN pip install --upgrade pip \ + && pip install git+https://github.com/codewars/python-test-framework.git#egg=codewars_test + +USER ${UNAME} +WORKDIR /codewars/python311 + +# setup +VOLUME "${PIPCACHE}" \ No newline at end of file diff --git a/README.md b/README.md index 44ee5c0..47c0407 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,14 @@ Use the build script in order to build the custom Python 3.11 Docker image `andrerademacher/codewars-python311`. ```bash -container/build.sh +ci/build_docker_image.sh ``` ## Run command in container The `container.sh` script makes running commands in the Docker container easy! -To open a shell, just add the "sh" command: +To open a shell, just add the "bash" command: ```bash -container.sh sh +container.sh bash ``` The current Python version can be shown like this: diff --git a/container/build.sh b/ci/build_docker_image.sh similarity index 88% rename from container/build.sh rename to ci/build_docker_image.sh index e3336d9..44f949a 100755 --- a/container/build.sh +++ b/ci/build_docker_image.sh @@ -3,7 +3,8 @@ SCRIPT_DIRECTORY="$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")" cd "${SCRIPT_DIRECTORY}" || exit -docker build \ +cd .. \ +&& docker build \ --no-cache \ --pull \ --tag "andrerademacher/codewars-python311" \ diff --git a/container.sh b/container.sh index 3233351..e7e2a0a 100755 --- a/container.sh +++ b/container.sh @@ -8,7 +8,6 @@ docker run \ --name 'codewars-python311' \ --rm \ --tty \ - --user "$(id -u)":"$(id -g)" \ - --volume "${PWD}/.cache":/.cache \ + --volume "pipcache":/.cache \ --volume "${PWD}":/codewars/python311 \ andrerademacher/codewars-python311 "$@" diff --git a/container/Dockerfile b/container/Dockerfile deleted file mode 100644 index d52ab55..0000000 --- a/container/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM python:3.11-alpine -LABEL maintainer="andre.rademacher.business@googlemail.com" -RUN apk add git \ - && pip install --upgrade pip \ - && pip install git+https://github.com/codewars/python-test-framework.git#egg=codewars_test -USER 1000 -WORKDIR /codewars/python311 \ No newline at end of file diff --git a/kata/GetNthEvenNumber/Instructions.md b/kata/GetNthEvenNumber/README.md similarity index 100% rename from kata/GetNthEvenNumber/Instructions.md rename to kata/GetNthEvenNumber/README.md diff --git a/kata/GetNthEvenNumber/test_NthEven.py b/kata/GetNthEvenNumber/test_NthEven.py index a04906e..c66f0a5 100644 --- a/kata/GetNthEvenNumber/test_NthEven.py +++ b/kata/GetNthEvenNumber/test_NthEven.py @@ -2,7 +2,7 @@ from kata.GetNthEvenNumber.NthEven import nth_even -@test.describe("Tests for nth even number") +@test.describe("nth even number kata") def nth_even_test(): @test.it("positive input values") def positive_input_values(): diff --git a/kata/RemoveTheTime/Instructions.md b/kata/RemoveTheTime/README.md similarity index 100% rename from kata/RemoveTheTime/Instructions.md rename to kata/RemoveTheTime/README.md diff --git a/kata/RemoveTheTime/test_Remove.py b/kata/RemoveTheTime/test_Remove.py index cd3f0a0..db78c04 100644 --- a/kata/RemoveTheTime/test_Remove.py +++ b/kata/RemoveTheTime/test_Remove.py @@ -2,7 +2,7 @@ from kata.RemoveTheTime.Remove import shorten_to_date -@test.describe("Basic Tests") +@test.describe("Remove the time kata") def basic_tests(): @test.it("Basic Tests") def basic_tests():