env: add additional target for building env images

Revise Makefile in linux-x86-std-kube and linux-x86-nacl:

- Support a target named `dev` that allows specifying a non-default
  Docker repository name.

- Replace hard-coded image names with the directory name that Makefile
  resides in. This uses the existing convention of naming directories
  according to image name.

- When Dockerfile inherits from a custom image (i.e., linux-x86-nacl
  inherits FROM linux-x86-std-kube), use sed to dynamically set the
  repository prefix in the Dockerfile.

Change-Id: I372c834175a38bb34d80a18f2f0e23c5a1d007af
Reviewed-on: https://go-review.googlesource.com/19021
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Evan Brown 2016-01-27 14:25:27 -08:00
Родитель 662ec3ac54
Коммит c514b80fed
4 изменённых файлов: 52 добавлений и 11 удалений

2
env/linux-x86-nacl/Dockerfile поставляемый
Просмотреть файл

@ -7,7 +7,7 @@
# We need more modern libc than Debian stable as used in base, so we're
# using Debian sid instead.
FROM gcr.io/symbolic-datum-552/linux-x86-std:latest
FROM {{REPO}}/linux-x86-std:latest
MAINTAINER golang-dev <golang-dev@googlegroups.com>
ENV DEBIAN_FRONTEND noninteractive

27
env/linux-x86-nacl/Makefile поставляемый
Просмотреть файл

@ -1,13 +1,30 @@
# Copyright 2015 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
IMAGE_NAME=$(shell basename $(CURDIR))
STAGING_REPO=gcr.io/go-dashboard-dev
PROD_REPO=gcr.io/symbolic-datum-552
usage:
echo "Use staging or prod targets" ; exit 1
echo "Use staging, prod, or dev targets. For dev, specify your Docker repository with the REPO=foo argument." ; exit 1
staging: Dockerfile
docker build -t gcr.io/go-dashboard-dev/linux-x86-nacl:latest .
gcloud docker push gcr.io/go-dashboard-dev/linux-x86-nacl:latest
sed 's|{{REPO}}|'"$(STAGING_REPO)"'|g' Dockerfile > Dockerfile.make
docker build -t $(STAGING_REPO)/$(IMAGE_NAME):latest -f Dockerfile.make .
gcloud docker push $(STAGING_REPO)/$(IMAGE_NAME):latest
rm Dockerfile.make
prod: Dockerfile
docker build -t gcr.io/symbolic-datum-552/linux-x86-nacl:latest .
gcloud docker push gcr.io/symbolic-datum-552/linux-x86-nacl:latest
sed 's|{{REPO}}|'"$(PROD_REPO)"'|g' Dockerfile > Dockerfile.make
docker build -t $(PROD_REPO)/$(IMAGE_NAME):latest -f Dockerfile.make .
gcloud docker push $(PROD_REPO)/$(IMAGE_NAME):latest
rm Dockerfile.make
# You must provide a REPO=your-repo-name arg when you make
# this targarget. REPO is the name of the Docker repository
# that will be prefixed to the name of the image being built.
dev: Dockerfile
sed 's|{{REPO}}|'"$(REPO)"'|g' Dockerfile > Dockerfile.make
docker build -t $(REPO)/$(IMAGE_NAME):latest -f Dockerfile.make .
gcloud docker push $(REPO)/$(IMAGE_NAME):latest
rm Dockerfile.make

13
env/linux-x86-nacl/README поставляемый
Просмотреть файл

@ -1,3 +1,16 @@
# Building Docker image
If you have access to the Go build staging project (`go-dashboard-dev`) or
production project (`symbolic-datum-552`), use the `make staging` or `make
prod` targets to build a Docker image and push it to the correct Docker
repository.
To build the image for your own dev environment, first build the
`linux-x86-std-kube` image with `make dev REPO=your/docker/repo/prefix`, then
build this image using the same repo prefix, i.e.,
`make dev REPO=your/docker/repo/prefix`.
# Running locally
$ export BUILD=nacl-amd64p32-temp
$ export BUILDREV=59b1bb4bf045
$ docker run \

21
env/linux-x86-std-kube/Makefile поставляемый
Просмотреть файл

@ -1,13 +1,24 @@
# Copyright 2015 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
IMAGE_NAME=$(shell basename $(CURDIR))
STAGING_REPO=gcr.io/go-dashboard-dev
PROD_REPO=gcr.io/symbolic-datum-552
usage:
echo "Use staging or prod targets" ; exit 1
echo "Use staging, prod, or dev targets. For dev, specify your Docker repository with the REPO=foo argument." ; exit 1
staging: Dockerfile
docker build -t gcr.io/go-dashboard-dev/linux-x86-std:latest .
gcloud docker push gcr.io/go-dashboard-dev/linux-x86-std:latest
docker build -t $(STAGING_REPO)/$(IMAGE_NAME):latest .
gcloud docker push $(STAGING_REPO)/$(IMAGE_NAME):latest
prod: Dockerfile
docker build -t gcr.io/symbolic-datum-552/linux-x86-std:latest .
gcloud docker push gcr.io/symbolic-datum-552/linux-x86-std:latest
docker build -t $(PROD_REPO)/$(IMAGE_NAME):latest .
gcloud docker push $(PROD_REPO)/$(IMAGE_NAME):latest
# You must provide a REPO=your-repo-name arg when you make
# this targarget. REPO is the name of the Docker repository
# that will be prefixed to the name of the image being built.
dev: Dockerfile
docker build -t $(REPO)/$(IMAGE_NAME):latest .
gcloud docker push $(REPO)/$(IMAGE_NAME):latest