diff options
-rw-r--r-- | cookiecutter.json | 2 | ||||
-rw-r--r-- | {{cookiecutter.project_name}}/Makefile | 15 | ||||
-rw-r--r-- | {{cookiecutter.project_name}}/docker-compose.yml | 14 | ||||
-rw-r--r-- | {{cookiecutter.project_name}}/docker/Dockerfile | 8 | ||||
-rw-r--r-- | {{cookiecutter.project_name}}/docker/entry.sh | 3 |
5 files changed, 23 insertions, 19 deletions
diff --git a/cookiecutter.json b/cookiecutter.json index 21ca891..2ba4ed0 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -1,4 +1,4 @@ { "project_name": "myprojectname", - "docker_namespace": "testing" + "docker_owner": "docker_username" } diff --git a/{{cookiecutter.project_name}}/Makefile b/{{cookiecutter.project_name}}/Makefile index 921561c..804034d 100644 --- a/{{cookiecutter.project_name}}/Makefile +++ b/{{cookiecutter.project_name}}/Makefile @@ -1,22 +1,19 @@ .PHONY: build -CONTAINERNAME={{cookiecutter.docker_namespace}}_{{cookiecutter.project_name}} -IMAGENAME={{cookiecutter.docker_namespace}}/{{cookiecutter.project_name}} - help: @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' build: ## Build the Docker image - docker build -t $(IMAGENAME) ./docker + docker-compose -p {{cookiecutter.project_name}} build up: build ## Bring the container up - docker run -dP -v $(CURDIR):/app --name $(CONTAINERNAME) $(IMAGENAME) /bin/bash -c '/opt/entry.sh' + docker-compose -p {{cookiecutter.project_name}} up -d down: ## Stop the container - docker stop $(CONTAINERNAME) || echo 'No container to stop' + docker-compose -p {{cookiecutter.project_name}} stop enter: ## Enter the running container - docker exec -it $(CONTAINERNAME) /bin/bash + docker-compose -p {{cookiecutter.project_name}} exec /bin/bash backend -clean: down ## Remove the image and any stopped containers - docker rm $(CONTAINERNAME) || echo 'No container to remove' +clean: down ## Remove stoped containers + docker-compose -p {{cookiecutter.project_name}} rm diff --git a/{{cookiecutter.project_name}}/docker-compose.yml b/{{cookiecutter.project_name}}/docker-compose.yml new file mode 100644 index 0000000..18e410e --- /dev/null +++ b/{{cookiecutter.project_name}}/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3' +services: + backend: + build: ./docker/ + network_mode: "bridge" + container_name: {{cookiecutter.project_name}} + image: {{cookiecutter.docker_owner}}/{{cookiecutter.project_name}} + ports: + - "8000" + volumes: + - .:/usr/src/app + command: /bin/bash + tty: true + stdin_open: true diff --git a/{{cookiecutter.project_name}}/docker/Dockerfile b/{{cookiecutter.project_name}}/docker/Dockerfile index ebbbe32..81d4aab 100644 --- a/{{cookiecutter.project_name}}/docker/Dockerfile +++ b/{{cookiecutter.project_name}}/docker/Dockerfile @@ -16,9 +16,5 @@ ENV LANG en_US.UTF-8 ENV LANGUAGE en_US:en ENV LC_ALL en_US.UTF-8 -# The code should be symlinked to this directory -WORKDIR /app - -# Create the entry script -ADD entry.sh /opt/ -RUN chmod 755 /opt/entry.sh +# The code is stored here +WORKDIR /usr/src/app diff --git a/{{cookiecutter.project_name}}/docker/entry.sh b/{{cookiecutter.project_name}}/docker/entry.sh deleted file mode 100644 index 09a943f..0000000 --- a/{{cookiecutter.project_name}}/docker/entry.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -while true; do echo hi; sleep 1; done; |