Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
improve Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Jan 5, 2019
1 parent 738e15a commit 49d8307
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
2 changes: 0 additions & 2 deletions env/.env.example
@@ -1,5 +1,3 @@
PACKAGE=github.com/kamilsk/passport

LOCAL_DB_PORT=5432
LOCAL_SERVER_HTTP_PORT=80
LOCAL_SERVER_HTTPS_PORT=443
Expand Down
6 changes: 2 additions & 4 deletions env/docker.mk
@@ -1,15 +1,13 @@
IMAGE_VERSION := 1.x
PACKAGE := github.com/kamilsk/passport


.PHONY: docker-build
docker-build:
docker build -f env/Dockerfile \
docker build -f env/docker/service/Dockerfile \
-t kamilsk/passport:$(IMAGE_VERSION) \
-t kamilsk/passport:latest \
-t quay.io/kamilsk/passport:$(IMAGE_VERSION) \
-t quay.io/kamilsk/passport:latest \
--build-arg PACKAGE=$(PACKAGE) \
--force-rm --no-cache --pull --rm \
.

Expand Down Expand Up @@ -45,7 +43,7 @@ docker-start:
-p 8091:8091 \
-p 8092:8092 \
-p 8093:8093 \
kamilsk/passport:$(IMAGE_VERSION)
kamilsk/passport:$(IMAGE_VERSION) run --with-profiling --with-monitoring

.PHONY: docker-logs
docker-logs:
Expand Down
2 changes: 0 additions & 2 deletions env/docker/compose/docker-compose.dev.yml
Expand Up @@ -10,13 +10,11 @@ services:

migration:
build:
args: { PACKAGE: "${PACKAGE}" }
context: ../../../.
dockerfile: ./env/docker/service/Dockerfile

service:
build:
args: { PACKAGE: "${PACKAGE}" }
context: ../../../.
dockerfile: ./env/docker/service/Dockerfile
ports:
Expand Down
11 changes: 5 additions & 6 deletions env/docker/service/Dockerfile
@@ -1,21 +1,20 @@
FROM golang:latest AS build

ARG PACKAGE

WORKDIR /go/src/${PACKAGE}
WORKDIR /src

ADD . .

ENV GOOS linux
ENV GOARCH amd64
ENV CGO_ENABLED 0
ENV GO111MODULE on

RUN echo "os: ${GOOS}" "arch: ${GOARCH}" "cgo: ${CGO_ENABLED}" \
RUN go env \
&& export _commit="-X main.commit=$(git rev-parse --short HEAD || echo 'none')" \
&& export _date="-X main.date=$(date -u +%FT%X%Z || echo 'unknown')" \
&& export _version="-X main.version=$(git describe --tags 2>&- || echo 'dev' | cut -d - -f 1)" \
&& go build -o /go/bin/service \
-ldflags "-s -w ${_commit} ${_date} ${_version}" .
-ldflags "-s -w ${_commit} ${_date} ${_version}" -mod vendor .


FROM alpine:latest AS service
Expand All @@ -26,7 +25,7 @@ RUN adduser -D -H -u 1000 service
USER service

COPY --from=build /go/bin/service /usr/local/bin/
COPY ./public/js/fingerprint2.min.js /usr/share/passport/
COPY --from=build /src/web/js/ /usr/share/passport/

ENV BIND=0.0.0.0 \
HTTP_PORT=8080 \
Expand Down

0 comments on commit 49d8307

Please sign in to comment.