Update makefile

This commit is contained in:
Lilian Roller 2019-03-06 13:25:48 +01:00
parent a466088b59
commit ad3aeceb07
No known key found for this signature in database
GPG key ID: 5215C3441797AB2B

View file

@ -19,7 +19,8 @@ sass-uncompressed:
lektor build lektor build
install: install:
pip install lektor pip install lektor --user
gem install sass
build: sass build: sass
lektor build lektor build
@ -27,49 +28,3 @@ build: sass
server: server:
lektor server $(LEKTOR_SERVER_FLAGS) lektor server $(LEKTOR_SERVER_FLAGS)
## Docker stuff
IMAGE_TAG:=v1.2.0
IMAGE:=toolboxbodensee/lektor:$(IMAGE_TAG)
PWD:=$(shell pwd)
CACHE:=$(HOME)/.cache
PWD:=$(shell pwd)
LEKTOR_CACHE:=$(CACHE)/lektor
CACHE_VOL:=-v $(CACHE)/lektor:/home/lektor/.cache/lektor
SOURCE_VOL:=-v $(PWD):/opt/lektor
EXPORTED_PORTS=-p 5000:5000
DOCKER:=docker
# On linux...
ifeq ($(shell uname),Linux)
# When user is not in docker group
ifneq ($(findstring docker,$(shell groups)),docker)
# And the user is not root
ifneq ($(shell whoami),root)
# Run docker client inside docker group
DOCKER:=sudo -E -g docker docker
endif
endif
endif
RUN:=run --rm -it $(SOURCE_VOL) $(CACHE_VOL)
$(LEKTOR_CACHE):
mkdir -p $(LEKTOR_CACHE)
docker-pull:
$(DOCKER) pull $(IMAGE)
docker-build: docker-pull $(LEKTOR_CACHE)
$(DOCKER) $(RUN) $(IMAGE) make build
docker-shell: $(LEKTOR_CACHE) docker-pull
$(DOCKER) $(RUN) $(EXPORTED_PORTS) $(IMAGE) /bin/sh
docker-server: $(LEKTOR_CACHE) docker-pull
$(DOCKER) $(RUN) $(EXPORTED_PORTS) $(IMAGE) make sass
$(DOCKER) $(RUN) $(EXPORTED_PORTS) $(IMAGE) lektor server -h 0.0.0.0