user/docker/user/Dockerfile-release
FROM golang:1.7-alpine COPY . /go/src/github.com/microservices-demo/user/ WORKDIR /go/src/github.com/microservices-demo/user/ RUN apk update RUN apk add git RUN go get -v github.com/Masterminds/glide RUN glide install && CGO_ENABLED=0 go build -a -installsuffix cgo -o /user main.go FROM alpine:3.4 ENV SERVICE_USER=myuser \ SERVICE_UID=10001 \ SERVICE_GROUP=mygroup \ SERVICE_GID=10001 RUN addgroup -g ${SERVICE_GID} ${SERVICE_GROUP} && \ adduser -g "${SERVICE_NAME} user" -D -H -G ${SERVICE_GROUP} -s /sbin/nologin -u ${SERVICE_UID} ${SERVICE_USER} && \ apk add --update libcap ENV HATEAOS user ENV USER_DATABASE mongodb ENV MONGO_HOST user-db WORKDIR / EXPOSE 80 COPY --from=0 /user / RUN chmod +x /user && \ chown -R ${SERVICE_USER}:${SERVICE_GROUP} /user && \ setcap 'cap_net_bind_service=+ep' /user USER ${SERVICE_USER} CMD ["/user", "-port=80"]
user/docker/user-db/Dockerfile
FROM mongo:3 ADD ./scripts /tmp/scripts # Modify child mongo to use /data/db-accounts as dbpath (because /data/db wont persist the build because it is already a VOLUME) RUN mkdir -p /data/db-users \ && echo "dbpath = /data/db-users" > /etc/mongodb.conf \ && chown -R mongodb:mongodb /data/db-users RUN su - mongodb && mongod --fork --logpath /var/log/mongodb.log --dbpath /data/db-users \ && /tmp/scripts/mongo_create_insert.sh \ && mongod --dbpath /data/db-users --shutdown \ && chown -R mongodb /data/db-users # Make the new dir a VOLUME to persist it VOLUME /data/db-users CMD ["mongod", "--config", "/etc/mongodb.conf", "--smallfiles"]
0 Comments