From f7e1a10e73886d703cbd6c0f32d898cf19538111 Mon Sep 17 00:00:00 2001 From: Mehrshad Lotfi Foroushani Date: Tue, 29 Aug 2023 10:59:46 +0200 Subject: [PATCH] Add Dockerfile and requirements.txt to repo. --- .devcontainer/python.Dockerfile | 11 +++++++++ Makefile | 43 +++++++++++++++++++++++++++++++++ requirements.txt | 3 +++ 3 files changed, 57 insertions(+) create mode 100644 .devcontainer/python.Dockerfile create mode 100644 Makefile create mode 100644 requirements.txt diff --git a/.devcontainer/python.Dockerfile b/.devcontainer/python.Dockerfile new file mode 100644 index 0000000..e3a3e1c --- /dev/null +++ b/.devcontainer/python.Dockerfile @@ -0,0 +1,11 @@ +FROM python:3 + +WORKDIR /opt/timer + +COPY requirements.txt /opt/timer/requirements.txt +COPY termdown.py /opt/timer/termdown.py + +RUN python3 -m pip install --no-cache-dir -r requirements.txt + + +ENTRYPOINT [ "python", "/opt/timer/termdown.py" ] \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..481a01a --- /dev/null +++ b/Makefile @@ -0,0 +1,43 @@ +.PHONY: help build-image + +CONTAINER_DIR ?= .devcontainer +WORK_DIR ?= $(shell pwd) +USERNAME ?= testuser +USER_UID ?= 1000 +USER_GID ?= 1000 + +IMAGE_NAME ?= termdown +CONTAINER_NAME ?= $(IMAGE_NAME)-$(USERNAME)-$(shell date +"%Y-%m-%d.%H-%M") +DOCKER_FILE ?= $(CONTAINER_DIR)/python.Dockerfile +DOCKER_ENTRYPOINT ?= +SHARED_DIRS ?= + + +define BUILD_IMAGE_HELP_INFO + build-image + Build the docker image +endef +export BUILD_IMAGE_HELP_INFO + +build-image: + @docker build -t $(IMAGE_NAME) \ + --build-arg DOCKER_ENTRYPOINT=$(DOCKER_ENTRYPOINT) \ + --file $(DOCKER_FILE) . + +# ============================================================================= # + +define RUN_CONTAINER_HELP_INFO + run-container + Run container from the docker image +endef +export RUN_CONTAINER_HELP_INFO + +run-container: + @docker run -it $(IMAGE_NAME) + +# ============================================================================= # + +help: + @echo "Usage: make [TARGET] [VARIABLE=value]\n" + @echo "$$BUILD_IMAGE_HELP_INFO\n" + @echo "$$RUN_CONTAINER_HELP_INFO\n" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..cefd6e2 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +Click +python-dateutil +pyfiglet \ No newline at end of file