Skip to content

Commit 22d45cb

Browse files
committed
Dockerfile optimization
1 parent 281444c commit 22d45cb

3 files changed

Lines changed: 9 additions & 19 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,6 @@ dmypy.json
243243

244244
# Cython debug symbols
245245
cython_debug/
246+
247+
# Project
248+
requirements.txt

Dockerfile

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,10 @@ ARG PYTHON_VERSION
22

33
FROM python:${PYTHON_VERSION}-buster
44

5-
ENV POETRY_VERSION=1.2.2
6-
75
WORKDIR /opt/app/
86

9-
RUN apt update \
10-
&& apt-get install -y wget \
11-
&& ln -s /root/.local/bin/poetry /usr/bin/poetry \
12-
&& wget -O get-poetry.py https://install.python-poetry.org \
13-
&& python ./get-poetry.py --version $POETRY_VERSION \
14-
&& poetry config virtualenvs.create false \
15-
&& rm ./get-poetry.py \
16-
&& apt-get purge -y wget \
17-
&& apt autoremove -y \
18-
&& apt autoclean -y \
19-
&& rm -fr /var/lib/apt/lists /var/lib/cache/* /var/log/* \
20-
&& touch README.md
21-
22-
COPY pyproject.toml poetry.lock /opt/app/
23-
RUN /bin/bash -c "mkdir -p src/runtime_config \
24-
&& touch src/runtime_config/__init__.py \
25-
&& poetry install --all-extras --no-interaction --no-ansi"
7+
COPY pyproject.toml requirements.txt /opt/app/
8+
RUN pip install -r requirements.txt
269

2710
COPY src/ /opt/app/src
2811
COPY tests/ /opt/app/tests

scripts/tests.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
SUPPORTED_VERSIONS=("3.8" "3.9" "3.10" "3.11")
22
EXIT_CODES=()
33

4+
poetry export --with dev --extras aiohttp --without-hashes -o requirements.txt
5+
46
for ver in "${SUPPORTED_VERSIONS[@]}"; do
57
docker build -q --build-arg PYTHON_VERSION=$ver -t test_runtime_config_py . &&
68
docker run --rm test_runtime_config_py
@@ -17,4 +19,6 @@ for code in "${EXIT_CODES[@]}"; do
1719
fi
1820
done
1921

22+
rm requirements.txt
23+
2024
echo "ALL TESTS COMPLETED SUCCESSFULLY!"

0 commit comments

Comments
 (0)