-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
IMAGE_TAG= | ||
PORT= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM alpine:latest | ||
|
||
ENTRYPOINT ["tail", "-f", "/dev/null"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
include .env | ||
|
||
ifndef IMAGE_TAG | ||
$(error IMAGE_TAG variable is not set. Ensure that an .env file is created and properly configured.) | ||
endif | ||
|
||
CONTAINERS_RUNNING != docker container ls -q --filter ancestor=$(IMAGE_TAG) | ||
CONTAINERS != docker container ls -aq --filter ancestor=$(IMAGE_TAG) | ||
|
||
all: build run | ||
|
||
build: | ||
docker build . --rm -t $(IMAGE_TAG) | ||
|
||
run: | ||
docker run -d --init --env-file=./.env $(if $(PORT),-p $(PORT):$(PORT)) $(IMAGE_TAG) | ||
|
||
stop: | ||
ifdef CONTAINERS_RUNNING | ||
docker container stop $(CONTAINERS_RUNNING) | ||
endif | ||
|
||
clean: stop | ||
ifdef CONTAINERS | ||
-docker container rm $(CONTAINERS) | ||
endif | ||
-docker rmi $(IMAGE_TAG) | ||
|
||
exec: | ||
docker exec -it $(word 1,$(CONTAINERS_RUNNING)) /bin/ash | ||
|
||
logs: | ||
docker logs $(word 1,$(CONTAINERS_RUNNING)) -f | ||
|
||
.PHONY: all build run stop clean exec logs |