From 8e9ce7d9990669da69b123967af1b56345b13943 Mon Sep 17 00:00:00 2001 From: Daniel Mai Date: Tue, 18 Aug 2020 14:58:01 -0700 Subject: [PATCH] build(standalone): Add DGRAPH_VERSION to build different Dgraph versions for standalone image. (#6082) (#6237) The standalone images build from the same tags as the `dgraph/dgraph` image. To build and push the v20.03.4 and latest `dgraph/standalone` images: # Build v20.03.4 make DGRAPH_VERSION=v20.03.4 make DGRAPH_VERSION=v20.03.4 push # Build latest. DGRAPH_VERSION defaults to latest make make push Changes * Add `DOCKER_IMAGE` and `DGRAPH_VERSION` arguments to build standalone Docker image. * Add ./hooks folder for Docker Hub auto-builds with `--build-arg`s (following [Custom build phase hooks](https://docs.docker.com/docker-hub/builds/advanced/#custom-build-phase-hooks) docs). --- contrib/standalone/Dockerfile | 3 ++- contrib/standalone/Dockerfile.master | 13 ---------- contrib/standalone/Makefile | 39 ++++++++++++++++++++++++++-- contrib/standalone/hooks/build | 3 +++ 4 files changed, 42 insertions(+), 16 deletions(-) delete mode 100644 contrib/standalone/Dockerfile.master create mode 100755 contrib/standalone/hooks/build diff --git a/contrib/standalone/Dockerfile b/contrib/standalone/Dockerfile index a0c964de9d2..f023bad1be9 100644 --- a/contrib/standalone/Dockerfile +++ b/contrib/standalone/Dockerfile @@ -1,4 +1,5 @@ -FROM dgraph/dgraph:latest +ARG DGRAPH_VERSION=latest +FROM dgraph/dgraph:${DGRAPH_VERSION} LABEL MAINTAINER="Dgraph Labs " # Ratel port diff --git a/contrib/standalone/Dockerfile.master b/contrib/standalone/Dockerfile.master deleted file mode 100644 index cc6bd4f20da..00000000000 --- a/contrib/standalone/Dockerfile.master +++ /dev/null @@ -1,13 +0,0 @@ -FROM dgraph/dgraph:master -LABEL MAINTAINER="Dgraph Labs " - -# Ratel port -EXPOSE 8000 -# REST API port -EXPOSE 8080 -# gRPC API port -EXPOSE 9080 - -ADD run.sh . -RUN chmod +x run.sh -CMD ["./run.sh"] diff --git a/contrib/standalone/Makefile b/contrib/standalone/Makefile index 0db31ad1daf..b06c1e730b6 100644 --- a/contrib/standalone/Makefile +++ b/contrib/standalone/Makefile @@ -1,3 +1,38 @@ -.PHONY: build +# Build dgraph/standalone image +# Usage: +# +# For latest tag: +# Build, based on dgraph/dgraph:latest: +# make +# Push: +# make push +# +# For $TAG tag, set DGRAPH_VERSION: +# Build, based on dgraph/dgraph:latest: +# make DGRAPH_VERSION=$TAG +# Push: +# make DGRAPH_VERSION=$TAG push +# +# Examples +# Build and push latest: +# make +# make push +# +# Build and push master: +# make DGRAPH_VERSION=master +# make DGRAPH_VERSION=master push +# +.PHONY: all build push version + +export DGRAPH_VERSION ?= latest + +all: build version + build: - docker build -t dgraph/standalone:latest . + ./hooks/build + +push: + docker push dgraph/standalone:$(DGRAPH_VERSION) + +version: + docker run dgraph/standalone:$(DGRAPH_VERSION) dgraph version diff --git a/contrib/standalone/hooks/build b/contrib/standalone/hooks/build new file mode 100755 index 00000000000..c9af4522026 --- /dev/null +++ b/contrib/standalone/hooks/build @@ -0,0 +1,3 @@ +#!/bin/bash +# Used for Makefile or Docker Hub builds +docker build -t dgraph/standalone:${DGRAPH_VERSION} --build-arg DGRAPH_VERSION=${DGRAPH_VERSION} .