2
0
mirror of https://github.com/woahbase/alpine-searx synced 2025-08-22 01:47:27 +00:00
alpine-searx/makefile

95 lines
2.6 KiB
Makefile
Raw Normal View History

2017-12-26 12:01:55 +05:30
# {{{ -- meta
HOSTARCH := x86_64# on travis.ci
ARCH := $(shell uname -m | sed "s_armv7l_armhf_")# armhf/x86_64 auto-detect on build and run
OPSYS := alpine
SHCOMMAND := /bin/bash
SVCNAME := searx
USERNAME := woahbase
PUID := $(shell id -u)
PGID := $(shell id -g)# gid 100(users) usually pre exists
2017-12-26 12:10:29 +05:30
DOCKERSRC := $(OPSYS)-python2#
2017-12-26 12:01:55 +05:30
DOCKEREPO := $(OPSYS)-$(SVCNAME)
IMAGETAG := $(USERNAME)/$(DOCKEREPO):$(ARCH)
# -- }}}
# {{{ -- flags
BUILDFLAGS := --rm --force-rm --compress -f $(CURDIR)/Dockerfile_$(ARCH) -t $(IMAGETAG) \
--build-arg ARCH=$(ARCH) \
--build-arg DOCKERSRC=$(DOCKERSRC) \
--build-arg USERNAME=$(USERNAME) \
--build-arg PUID=$(PUID) \
--build-arg PGID=$(PGID) \
--label org.label-schema.build-date=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") \
--label org.label-schema.name=$(DOCKEREPO) \
--label org.label-schema.schema-version="1.0" \
--label org.label-schema.vcs-ref=$(shell git rev-parse --short HEAD) \
--label org.label-schema.vcs-url="https://github.com/$(USERNAME)/$(DOCKEREPO)" \
--label org.label-schema.vendor=$(USERNAME)
CACHEFLAGS := --no-cache=true --pull
MOUNTFLAGS := -v $(CURDIR)/data:/data
NAMEFLAGS := --name docker_$(SVCNAME) --hostname $(SVCNAME)
OTHERFLAGS := -v /etc/hosts:/etc/hosts:ro -v /etc/localtime:/etc/localtime:ro # -e TZ=Asia/Kolkata
PORTFLAGS := -p 8888:8888
PROXYFLAGS := --build-arg http_proxy=$(http_proxy) --build-arg https_proxy=$(https_proxy) --build-arg no_proxy=$(no_proxy)
RUNFLAGS := -c 512 -m 512m -e PGID=$(PGID) -e PUID=$(PUID)
# -- }}}
# {{{ -- docker targets
all : run
build :
echo "Building for $(ARCH) from $(HOSTARCH)";
if [ "$(ARCH)" != "$(HOSTARCH)" ]; then make regbinfmt ; fi;
docker build $(BUILDFLAGS) $(CACHEFLAGS) $(PROXYFLAGS) .
clean :
docker images | awk '(NR>1) && ($$2!~/none/) {print $$1":"$$2}' | grep "$(USERNAME)/$(DOCKEREPO)" | xargs -n1 docker rmi
logs :
docker logs -f docker_$(SVCNAME)
pull :
docker pull $(IMAGETAG)
push :
docker push $(IMAGETAG)
restart :
docker ps -a | grep 'docker_$(SVCNAME)' -q && docker restart docker_$(SVCNAME) || echo "Service not running.";
rm : stop
docker rm -f docker_$(SVCNAME)
run :
docker run --rm -it $(NAMEFLAGS) $(RUNFLAGS) $(PORTFLAGS) $(MOUNTFLAGS) $(OTHERFLAGS) $(IMAGETAG)
rshell :
docker exec -u root -it docker_$(SVCNAME) $(SHCOMMAND)
shell :
docker exec -it docker_$(SVCNAME) $(SHCOMMAND)
stop :
docker stop -t 2 docker_$(SVCNAME)
test :
docker run --rm -it $(NAMEFLAGS) $(RUNFLAGS) $(PORTFLAGS) $(MOUNTFLAGS) $(OTHERFLAGS) $(IMAGETAG) sh -ec 'sleep 15; python -V'
# -- }}}
# {{{ -- other targets
regbinfmt :
docker run --rm --privileged multiarch/qemu-user-static:register --reset
# -- }}}