Makefile: add rules for docker image build

This commit is contained in:
Zlatko Čalušić
2017-10-18 23:38:18 +02:00
parent ebe3bc04b5
commit ca5664b8a7
3 changed files with 22 additions and 13 deletions

View File

@@ -9,7 +9,7 @@ COPY rest-server docker/*_user /usr/bin/
VOLUME /data
EXPOSE 80
EXPOSE 80
COPY docker/entrypoint.sh /entrypoint.sh

View File

@@ -1,4 +1,11 @@
.PHONY: default rest-server install uninstall clean
# Copyright © 2017 Zlatko Čalušić
#
# Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.
#
DOCKER_IMAGE ?= restic/rest-server
.PHONY: default rest-server install uninstall docker_build docker_push clean
default: rest-server
@@ -11,5 +18,18 @@ install: rest-server
uninstall:
sudo rm -f /usr/local/bin/rest-server
docker_build:
docker pull golang:1.9.1-alpine
docker run --rm -it \
-v $(CURDIR):/go/src/github.com/restic/rest-server \
-w /go/src/github.com/restic/rest-server \
golang:1.9.1-alpine \
go run build.go
docker pull alpine:3.6
docker build -t $(DOCKER_IMAGE) .
docker_push:
docker push $(DOCKER_IMAGE):latest
clean:
rm -f rest-server

View File

@@ -1,11 +0,0 @@
#!/bin/sh
set -e
echo "Build binary using golang docker image"
docker run --rm -ti \
-v `pwd`:/go/src/github.com/restic/rest-server \
-w /go/src/github.com/restic/rest-server golang:1.9.1-alpine go run build.go
echo "Build docker image restic/rest-server:latest"
docker build --rm -t restic/rest-server:latest -f docker/Dockerfile .