Skip to content

Commit

Permalink
Merge pull request #104 from resgateio/feature/gh-92-scratch-docker-i…
Browse files Browse the repository at this point in the history
…mage

Feature/gh 92 scratch docker image
  • Loading branch information
jirenius committed Aug 5, 2019
2 parents e03c370 + a5b1d85 commit cb5ce1f
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM golang

WORKDIR $GOPATH/src/github.com/resgateio/resgate
COPY . .

RUN go get -d -v
RUN CGO_ENABLED=0 GO111MODULE=off go install -v -ldflags "-s -w"

EXPOSE 8080

ENTRYPOINT ["resgate"]
CMD ["--help"]
28 changes: 28 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM golang:1.12.5-alpine3.9 as builder

LABEL maintainer="Samuel Jirenius <samuel@jirenius.com>"

WORKDIR $GOPATH/src/github.com/resgateio/resgate

RUN apk update && apk add --no-cache git ca-certificates && update-ca-certificates
RUN mkdir /user && \
echo 'nobody:x:65534:65534:nobody:/:' > /user/passwd && \
echo 'nobody:x:65534:' > /user/group

COPY . .

RUN go get -d -v
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=off go build -v -ldflags "-s -w" -o /resgate

FROM scratch

COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /user/group /user/passwd /etc/
COPY --from=builder /resgate /resgate

EXPOSE 8080

USER nobody:nobody

ENTRYPOINT ["/resgate"]
CMD ["--config", "config.json"]
23 changes: 23 additions & 0 deletions docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM golang:1.12.5-alpine3.9 as builder

LABEL maintainer="Samuel Jirenius <samuel@jirenius.com>"

WORKDIR $GOPATH/src/github.com/resgateio/resgate

RUN apk add --update git

COPY . .

RUN go get -d -v
RUN GO111MODULE=off go build -v -ldflags "-s -w" -o /resgate

FROM alpine:3.9

RUN apk add --update ca-certificates

COPY --from=builder /resgate /bin/resgate

EXPOSE 8080

ENTRYPOINT ["/bin/resgate"]
CMD [""]
2 changes: 2 additions & 0 deletions nats/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ func (c *Client) Connect() error {
c.mu.Lock()
defer c.mu.Unlock()

c.Logf("Connecting to NATS at %s", c.URL)

// No reconnects as all resources are instantly stale anyhow
nc, err := nats.Connect(c.URL, nats.NoReconnect())
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion server/mqClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ func (s *Service) initMQClient() {
// startMQClients creates a connection to the messaging system.
// Service.mu is held when called
func (s *Service) startMQClient() error {
s.Logf("Connecting to messaging system")
if err := s.mq.Connect(); err != nil {
return err
}
Expand Down

0 comments on commit cb5ce1f

Please sign in to comment.