From d0a2f6121325d157580bb6d5dbf23a53e3aacfa7 Mon Sep 17 00:00:00 2001 From: Artem Veremey Date: Sat, 21 Aug 2021 12:55:17 -0700 Subject: [PATCH] Rewriting Dockerfiles with dynamic parameters (#695) * Rewriting Dockerfiles with dynamic parameters * Adding procps, bumping python container version and adding a source label --- docker/compose.env | 17 +++++++++++ docker/docker-compose.yaml | 40 ++++++++++++++++++++++---- docker/gst-deps.dockerfile | 4 ++- docker/gst-poetry-deps.dockerfile | 4 ++- docker/gst-poetry-full-deps.dockerfile | 11 +++++++ docker/gst-poetry-full.dockerfile | 7 +++++ docker/gst-poetry.dockerfile | 4 ++- docker/gst-python.dockerfile | 3 ++ docker/gst.dockerfile | 4 ++- 9 files changed, 85 insertions(+), 9 deletions(-) create mode 100644 docker/compose.env create mode 100644 docker/gst-poetry-full-deps.dockerfile create mode 100644 docker/gst-poetry-full.dockerfile diff --git a/docker/compose.env b/docker/compose.env new file mode 100644 index 00000000000..85aac35b0a2 --- /dev/null +++ b/docker/compose.env @@ -0,0 +1,17 @@ +GST_DOCKER_IMAGE_PREFIX="ghcr.io/gamestonkterminal" +GST_DOCKER_PYTHON_VERSION="1.1.0" +GST_DOCKER_DEPS_VERSION="1.2.0" +GST_DOCKER_POETRY_DEPS_VERSION="1.2.0" +GST_DOCKER_POETRY_FULL_DEPS_VERSION="1.2.0" +GST_DOCKER_GST_VERSION="1.2.0" +GST_DOCKER_POETRY_VERSION="1.2.0" +GST_DOCKER_POETRY_FULL_VERSION="1.2.0" + +export GST_DOCKER_IMAGE_PREFIX +export GST_DOCKER_PYTHON_VERSION +export GST_DOCKER_DEPS_VERSION +export GST_DOCKER_POETRY_DEPS_VERSION +export GST_DOCKER_POETRY_FULL_DEPS_VERSION +export GST_DOCKER_GST_VERSION +export GST_DOCKER_POETRY_VERSION +export GST_DOCKER_POETRY_FULL_VERSION diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index d5cbce63305..a71dfcdd153 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -4,28 +4,58 @@ services: build: context: .. dockerfile: docker/gst-python.dockerfile - image: gst/gst-python:1.0.0 + image: "${GST_DOCKER_IMAGE_PREFIX}/gst-python:${GST_DOCKER_PYTHON_VERSION}" gst-deps: build: context: .. dockerfile: docker/gst-deps.dockerfile - image: gst/gst-deps:1.0.0 + args: + GST_DOCKER_IMAGE_PREFIX: ${GST_DOCKER_IMAGE_PREFIX} + GST_DOCKER_PYTHON_VERSION: ${GST_DOCKER_PYTHON_VERSION} + image: "${GST_DOCKER_IMAGE_PREFIX}/gst-deps:${GST_DOCKER_DEPS_VERSION}" gst-poetry-deps: build: context: .. dockerfile: docker/gst-poetry-deps.dockerfile - image: gst/gst-poetry-deps:1.0.0 + args: + GST_DOCKER_IMAGE_PREFIX: ${GST_DOCKER_IMAGE_PREFIX} + GST_DOCKER_PYTHON_VERSION: ${GST_DOCKER_PYTHON_VERSION} + image: "${GST_DOCKER_IMAGE_PREFIX}/gst-poetry-deps:${GST_DOCKER_POETRY_DEPS_VERSION}" + gst-poetry-full-deps: + build: + context: .. + dockerfile: docker/gst-poetry-full-deps.dockerfile + args: + GST_DOCKER_IMAGE_PREFIX: ${GST_DOCKER_IMAGE_PREFIX} + GST_DOCKER_PYTHON_VERSION: ${GST_DOCKER_PYTHON_VERSION} + image: "${GST_DOCKER_IMAGE_PREFIX}/gst-poetry-full-deps:${GST_DOCKER_POETRY_FULL_DEPS_VERSION}" gst: build: context: .. dockerfile: docker/gst.dockerfile - image: gst/gst:1.1.0 + args: + GST_DOCKER_IMAGE_PREFIX: ${GST_DOCKER_IMAGE_PREFIX} + GST_DOCKER_DEPS_VERSION: ${GST_DOCKER_DEPS_VERSION} + image: "${GST_DOCKER_IMAGE_PREFIX}/gst:${GST_DOCKER_GST_VERSION}" tty: true env_file: setenv gst-poetry: build: context: .. dockerfile: docker/gst-poetry.dockerfile - image: gst/gst-poetry:1.1.0 + args: + GST_DOCKER_IMAGE_PREFIX: ${GST_DOCKER_IMAGE_PREFIX} + GST_DOCKER_POETRY_DEPS_VERSION: ${GST_DOCKER_POETRY_DEPS_VERSION} + image: "${GST_DOCKER_IMAGE_PREFIX}/gst-poetry:${GST_DOCKER_POETRY_VERSION}" + tty: true + env_file: setenv + gst-poetry-full: + build: + context: .. + dockerfile: docker/gst-poetry-full.dockerfile + args: + GST_DOCKER_IMAGE_PREFIX: ${GST_DOCKER_IMAGE_PREFIX} + GST_DOCKER_POETRY_DEPS_VERSION: ${GST_DOCKER_POETRY_FULL_DEPS_VERSION} + image: "${GST_DOCKER_IMAGE_PREFIX}/gst-poetry-full:${GST_DOCKER_POETRY_FULL_VERSION}" tty: true env_file: setenv diff --git a/docker/gst-deps.dockerfile b/docker/gst-deps.dockerfile index b9c6074028a..38409c0e5b2 100644 --- a/docker/gst-deps.dockerfile +++ b/docker/gst-deps.dockerfile @@ -1,4 +1,6 @@ -FROM gst/gst-python:1.0.0 +ARG GST_DOCKER_IMAGE_PREFIX="ghcr.io/gamestonkterminal" +ARG GST_DOCKER_PYTHON_VERSION="1.0.0" +FROM ${GST_DOCKER_IMAGE_PREFIX}/gst-python:${GST_DOCKER_PYTHON_VERSION} COPY --chown=python:python requirements.txt /home/python/ diff --git a/docker/gst-poetry-deps.dockerfile b/docker/gst-poetry-deps.dockerfile index 3aa06d18143..6824aedaf7a 100644 --- a/docker/gst-poetry-deps.dockerfile +++ b/docker/gst-poetry-deps.dockerfile @@ -1,4 +1,6 @@ -FROM gst/gst-python:1.0.0 +ARG GST_DOCKER_IMAGE_PREFIX="ghcr.io/gamestonkterminal" +ARG GST_DOCKER_PYTHON_VERSION="1.0.0" +FROM ${GST_DOCKER_IMAGE_PREFIX}/gst-python:${GST_DOCKER_PYTHON_VERSION} COPY --chown=python:python pyproject.toml poetry.lock /home/python/ diff --git a/docker/gst-poetry-full-deps.dockerfile b/docker/gst-poetry-full-deps.dockerfile new file mode 100644 index 00000000000..011bb980954 --- /dev/null +++ b/docker/gst-poetry-full-deps.dockerfile @@ -0,0 +1,11 @@ +ARG GST_DOCKER_IMAGE_PREFIX="ghcr.io/gamestonkterminal" +ARG GST_DOCKER_PYTHON_VERSION="1.0.0" +FROM ${GST_DOCKER_IMAGE_PREFIX}/gst-python:${GST_DOCKER_PYTHON_VERSION} + +COPY --chown=python:python pyproject.toml poetry.lock /home/python/ + +RUN mkdir /home/python/gamestonk_terminal && \ + touch gamestonk_terminal/__init__.py && \ + chown python:python /home/python/gamestonk_terminal /home/python/gamestonk_terminal/__init__.py && \ + poetry install && \ + poetry install -E prediction diff --git a/docker/gst-poetry-full.dockerfile b/docker/gst-poetry-full.dockerfile new file mode 100644 index 00000000000..baaa2527ba9 --- /dev/null +++ b/docker/gst-poetry-full.dockerfile @@ -0,0 +1,7 @@ +ARG GST_DOCKER_IMAGE_PREFIX="ghcr.io/gamestonkterminal" +ARG GST_DOCKER_POETRY_FULL_DEPS_VERSION="1.2.0" +FROM ${GST_DOCKER_IMAGE_PREFIX}/gst-poetry-full-deps:${GST_DOCKER_POETRY_FULL_DEPS_VERSION} + +COPY --chown=python:python . . + +CMD ["bash", "docker/entry-point-poetry.sh"] diff --git a/docker/gst-poetry.dockerfile b/docker/gst-poetry.dockerfile index 212ac7ff6a8..f00ff7de22f 100644 --- a/docker/gst-poetry.dockerfile +++ b/docker/gst-poetry.dockerfile @@ -1,4 +1,6 @@ -FROM gst/gst-poetry-deps:1.0.0 +ARG GST_DOCKER_IMAGE_PREFIX="ghcr.io/gamestonkterminal" +ARG GST_DOCKER_POETRY_DEPS_VERSION="1.2.0" +FROM ${GST_DOCKER_IMAGE_PREFIX}/gst-poetry-deps:${GST_DOCKER_POETRY_DEPS_VERSION} COPY --chown=python:python . . diff --git a/docker/gst-python.dockerfile b/docker/gst-python.dockerfile index 965a05e9969..c3370778fe4 100644 --- a/docker/gst-python.dockerfile +++ b/docker/gst-python.dockerfile @@ -1,5 +1,7 @@ FROM python:3.8-slim-buster +LABEL org.opencontainers.image.source https://github.com/GamestonkTerminal/GamestonkTerminal + RUN apt-get update && apt-get -y install --no-install-recommends \ gcc \ g++ \ @@ -18,6 +20,7 @@ RUN apt-get update && apt-get -y install --no-install-recommends \ libxt6 \ libgl1-mesa-glx \ libpng16-16 \ + procps \ python3-tk && \ apt-get -y autoremove && \ apt-get clean && \ diff --git a/docker/gst.dockerfile b/docker/gst.dockerfile index e7c66172a3d..4b58e291045 100644 --- a/docker/gst.dockerfile +++ b/docker/gst.dockerfile @@ -1,4 +1,6 @@ -FROM gst/gst-deps:1.0.0 +ARG GST_DOCKER_IMAGE_PREFIX="ghcr.io/gamestonkterminal" +ARG GST_DOCKER_DEPS_VERSION="1.2.0" +FROM ${GST_DOCKER_IMAGE_PREFIX}/gst-deps:${GST_DOCKER_DEPS_VERSION} COPY --chown=python:python . .