Skip to content

Commit

Permalink
Make docker build pipeline always use clean env and actaully work
Browse files Browse the repository at this point in the history
Previously it didn't always work because my local env was overriding
what was previously baked into image. Now the image bases only on source
code and is brand new each time.

It is also a lot faster when dockerignore excludes more files.
  • Loading branch information
bryk committed Mar 2, 2016
1 parent 5b59097 commit df9dd38
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
24 changes: 24 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
# Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Do not include the Docker build pipeline itself.
build/Dockerfile
build/run-gulp-in-docker.sh

# Ignore all development artifacts so that the build is always clean.
.git
.tmp/
.tools/
bower_components/
dist/
node_modules/
21 changes: 8 additions & 13 deletions Dockerfile → build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@

# This is a Dockerfile for running and building Kubernetes dashboard
# It installs all deps in the container and adds the dashboard source
# This way it abstracts all required build tools away and lets the user run gulp tasks on the code with only docker installed
# This way it abstracts all required build tools away and lets the user
# run gulp tasks on the code with only docker installed

# golang is based on debian:jessie
FROM golang:1.5.3
FROM golang

# Install python, java and nodejs. go is already installed
# A small tweak, apt-get update is already run by the nodejs setup script, so there's no need to run it again
# Install java and nodejs. go is already installed
# A small tweak, apt-get update is already run by the nodejs setup script,
# so there's no need to run it again
RUN curl -sL https://deb.nodesource.com/setup_5.x | bash - \
&& apt-get install -y --no-install-recommends \
file \
python \
openjdk-7-jre \
nodejs \
&& rm -rf /var/lib/apt/lists/* \
Expand All @@ -37,13 +37,8 @@ RUN curl -sSL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin
# Current directory is always /dashboard
WORKDIR /dashboard

# Copy over package.json bower.json and postinstall.sh.
# Why? Because of docker caching, npm install will only run again if one of these have changed
COPY package.json bower.json ./
COPY build/postinstall.sh build/
# Copy entire source tree.
COPY ./ ./

# Install all npm deps, bower deps and godep. This will take a while.
RUN npm install --unsafe-perm

# Copy over the rest of the source
COPY ./ ./
6 changes: 4 additions & 2 deletions build/run-gulp-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
DOCKER_RUN_OPTS=${DOCKER_RUN_OPTS:-}
DASHBOARD_IMAGE_NAME="kubernetes-dashboard-build-image"
DEFAULT_COMMAND=${DEFAULT_COMMAND:-"node_modules/.bin/gulp"}
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Always test if the image is up-to-date. If nothing has changed since last build, it'll just use the already-built image
docker build -t ${DASHBOARD_IMAGE_NAME} .
# Always test if the image is up-to-date. If nothing has changed since last build,
# it'll just use the already-built image
docker build -t ${DASHBOARD_IMAGE_NAME} -f ${DIR}/Dockerfile ${DIR}/../

# Run gulp in the container in interactive mode and expose necessary ports automatically
docker run \
Expand Down

0 comments on commit df9dd38

Please sign in to comment.