Skip to content

Commit

Permalink
run as non-root user in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
gonewest818 committed Mar 5, 2017
1 parent 870fb10 commit bbf3243
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@ FROM maven:latest

COPY . /usr/src/app
WORKDIR /usr/src/app

RUN useradd -m -u 1000 builder
RUN chown -R builder /usr/src/app
USER builder

RUN mvn clean compile

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
IMAGE_NAME := openstack4j-dev$(if $(GIT_BRANCH),:$(GIT_BRANCH))
DOCKER_RUN := docker run --rm -it --privileged $(IMAGE_NAME)
DOCKER_RUN := docker run --rm -it --privileged -e MAVEN_CONFIG=/home/builder/.m2 $(IMAGE_NAME)

default: build

Expand All @@ -21,4 +21,4 @@ package: build
$(DOCKER_RUN) mvn clean package

build:
docker build -t "$(IMAGE_NAME)" .
docker build -t "$(IMAGE_NAME)" .

0 comments on commit bbf3243

Please sign in to comment.