Skip to content

Commit 237eb3f

Browse files
committed
Fix running gulp in docker image
This simplifies Dockerfile and fixes bugs where it would produce errors on build. Fixes #315
1 parent fbcd4b1 commit 237eb3f

File tree

5 files changed

+7
-24
lines changed

5 files changed

+7
-24
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.git
1+
.git

Dockerfile

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,7 @@ RUN curl -sSL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin
3737
# Current directory is always /dashboard
3838
WORKDIR /dashboard
3939

40-
# Make an normal user, required for npm and bower, they are user programs and should not be called as root
41-
RUN useradd normaluser -m -s /bin/bash && \
42-
chown -R normaluser /dashboard
43-
# Our normal user should have access to /dashboard
44-
45-
# Switch user to normaluser
46-
USER normaluser
47-
48-
# Copy over package.json bower.json and postinstall.sh.
49-
# Why? Because of docker caching, npm install will only run again if one of these have changed
50-
COPY package.json bower.json ./
51-
COPY build/postinstall.sh build/
52-
53-
# Install all npm deps, bower deps and godep. This will take a while.
54-
RUN npm install
55-
56-
# Copy over the rest of the source
5740
COPY ./ ./
5841

59-
# Switch back to the root user when where going to communicate with docker
60-
USER root
42+
# Install all npm deps, bower deps and godep. This will take a while.
43+
RUN npm install --unsafe-perm

build/postinstall.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# This is a script that runs on npm install postinstall phase.
1717
# It contains all prerequisites required to use the build system.
1818

19-
./node_modules/.bin/bower install
19+
./node_modules/.bin/bower install --allow-root
2020

2121
# Godep is required by the project. Install it in the tools directory.
2222
GOPATH=`pwd`/.tools/go go get github.com/tools/godep

build/run-gulp-in-docker.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515

1616
# This is a script that runs gulp in a docker container,
17-
# for machines that doesn't have nodejs, go and java installed.
17+
# for machines that don't have nodejs, go and java installed.
1818

1919
DOCKER_RUN_OPTS=${DOCKER_RUN_OPTS:-}
2020
DASHBOARD_IMAGE_NAME="kubernetes-dashboard-build-image"
@@ -31,4 +31,4 @@ docker run \
3131
-v /var/run/docker.sock:/var/run/docker.sock \
3232
${DOCKER_RUN_OPTS} \
3333
${DASHBOARD_IMAGE_NAME} \
34-
${DEFAULT_COMMAND} $@
34+
${DEFAULT_COMMAND} $@

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@
7070
"node": ">=4.2.2"
7171
},
7272
"scripts": {
73-
"postinstall": "./build/postinstall.sh"
73+
"postinstall": "build/postinstall.sh"
7474
}
7575
}

0 commit comments

Comments
 (0)