40 lines
837 B
Makefile
40 lines
837 B
Makefile
BASENAME=interview
|
|
|
|
IMAGE_NAME=$(BASENAME):latest
|
|
MOUNT_DIR=$(shell realpath $(DIR))
|
|
|
|
help:
|
|
$(info make build to build the image)
|
|
$(info make run PORT=<port_to_expose> DIR=<dir_to_mount> SECRET=<password_for_ubuntu_user>)
|
|
|
|
build:
|
|
$(info BUILDING IMAGE NAME: $(IMAGE_NAME))
|
|
docker build \
|
|
-t $(IMAGE_NAME) \
|
|
-f Dockerfile .
|
|
docker image ls $(IMAGE_NAME)
|
|
|
|
run: check-env
|
|
$(info PORT: $(PORT) MOUNT: ${MOUNT_DIR} PASSWORD: $(SECRET))
|
|
docker run -it --rm --name interview \
|
|
-h interview \
|
|
-m 524288000 \
|
|
-e SECRET=$(SECRET) \
|
|
-p ${PORT}:22 \
|
|
-v ${MOUNT_DIR}:/home/ubuntu/interview:ro \
|
|
$(IMAGE_NAME) bash -c read "press Enter to stop"
|
|
|
|
check-env:
|
|
ifndef PORT
|
|
$(error no PORT, run make help)
|
|
endif
|
|
|
|
ifndef SECRET
|
|
$(error no SECRET, run make help)
|
|
endif
|
|
|
|
ifndef DIR
|
|
$(error no DIR, run make help)
|
|
endif
|
|
|