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

Commit

Permalink
Use vgo for dependency management (#72)
Browse files Browse the repository at this point in the history
* fix dockerfile path

* dockerfile not building

* use vgo in Dockerfile

* consistent dockerfiles

* use v0.0.1 for cursor, envy, and my-go-utils

* Makefile
  • Loading branch information
kevinmichaelchen committed Jul 4, 2018
1 parent ac8f08c commit 1681a44
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 45 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
.idea
bin/*
go.sum
3 changes: 2 additions & 1 deletion Makefile
Expand Up @@ -63,7 +63,8 @@ run-mfa:

.PHONY: test
test:
go test -v $(SERVICES_DIR)/auth
cd ${GOPATH}/src/github.com/hanakoa/alpaca/$(SERVICES_DIR)/auth && vgo test -v .
cd ${GOPATH}/src/github.com/hanakoa/alpaca/$(SERVICES_DIR)/password-reset && pwd

.PHONY: convey
convey:
Expand Down
4 changes: 2 additions & 2 deletions makefiles/docker.mk
Expand Up @@ -14,15 +14,15 @@ docker:
docker-build:
for svc in $(SERVICES); do \
echo Building image for $$svc; \
docker image build -t $(DOCKER_ORG)/alpaca-$$svc-api:$(DOCKER_IMAGE_VERSION) -t $(DOCKER_ORG)/alpaca-$$svc-api:latest -f $$svc/Dockerfile . ; \
docker image build -t $(DOCKER_ORG)/alpaca-$$svc-api:$(DOCKER_IMAGE_VERSION) -t $(DOCKER_ORG)/alpaca-$$svc-api:latest -f $(SERVICES_DIR)/$$svc/Dockerfile . ; \
done
docker-compose build

.PHONY: docker-rebuild
docker-rebuild:
for svc in $(SERVICES); do \
echo Rebuilding image for $$svc; \
docker image build -t $(DOCKER_ORG)/alpaca-$$svc-api:$(DOCKER_IMAGE_VERSION) -t $(DOCKER_ORG)/alpaca-$$svc-api:latest -f $$svc/Dockerfile . --no-cache ; \
docker image build -t $(DOCKER_ORG)/alpaca-$$svc-api:$(DOCKER_IMAGE_VERSION) -t $(DOCKER_ORG)/alpaca-$$svc-api:latest -f $(SERVICES_DIR)/$$svc/Dockerfile . --no-cache ; \
done
docker-compose build

Expand Down
13 changes: 3 additions & 10 deletions services/auth/Dockerfile
@@ -1,19 +1,12 @@
FROM golang:1.10 as builder
ADD . /go/src/github.com/hanakoa/alpaca
WORKDIR /go/src/github.com/hanakoa/alpaca/services/auth
RUN go get ./... && \
CGO_ENABLED=0 GOOS=linux go build -a -o ./bin/alpaca-auth .
# won't need to go get vgo in golang 1.11
RUN go get -u -v golang.org/x/vgo && \
CGO_ENABLED=0 GOOS=linux vgo build -a -o ./bin/alpaca-auth .

FROM alpine:latest
#ENV ALPACA_USER="alpaca" \
# ALPACA_UID="8080" \
# ALPACA_GROUP="alpaca" \
# ALPACA_GID="8080"
RUN apk --no-cache add ca-certificates
#&& \
# addgroup -S -g $ALPACA_GID $ALPACA_GROUP && \
# adduser -S -u $ALPACA_UID -G $ALPACA_GROUP $ALPACA_USER
WORKDIR /root/
COPY --from=builder /go/src/github.com/hanakoa/alpaca/services/auth/bin/alpaca-auth .
#USER $ALPACA_USER
CMD ["./alpaca-auth"]
32 changes: 32 additions & 0 deletions services/auth/go.mod
@@ -0,0 +1,32 @@
module github.com/hanakoa/alpaca/services/auth

require (
github.com/TeslaGov/cursor v0.0.1
github.com/TeslaGov/envy v0.0.1
github.com/badoux/checkmail v0.0.0-20180430153108-0755fe2dc241
github.com/bwmarrin/snowflake v0.0.0-20180412010544-68117e6bbede
github.com/dgrijalva/jwt-go v0.0.0-20180308231308-06ea1031745c
github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188
github.com/golang/protobuf v1.1.0
github.com/google/uuid v0.0.0-20171129191014-dec09d789f3d
github.com/gorilla/handlers v1.3.0
github.com/gorilla/mux v1.6.2
github.com/gorilla/schema v1.0.2
github.com/hanakoa/alpaca v0.0.0-20180703023732-ac8f08ce0dab
github.com/jtolds/gls v0.0.0-20170503224851-77f18212c9c7
github.com/kevinmichaelchen/my-go-utils v0.0.1
github.com/lib/pq v0.0.0-20180523175426-90697d60dd84
github.com/nbutton23/zxcvbn-go v0.0.0-20180510020640-780cc39d5c78
github.com/sfreiberg/gotwilio v0.0.0-20180612161623-8fb7259ba8bf
github.com/smartystreets/assertions v0.0.0-20180607162144-eb5b59917fa2
github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a
github.com/streadway/amqp v0.0.0-20180528204448-e5adc2ada8b8
github.com/ttacon/builder v0.0.0-20170518171403-c099f663e1c2
github.com/ttacon/libphonenumber v1.0.0
golang.org/x/crypto v0.0.0-20180621125126-a49355c7e3f8
golang.org/x/net v0.0.0-20180702212446-ed29d75add3d
golang.org/x/text v0.3.0
google.golang.org/genproto v0.0.0-20180627194029-ff3583edef7d
google.golang.org/grpc v1.13.0
gopkg.in/guregu/null.v3 v3.3.0
)
13 changes: 3 additions & 10 deletions services/email/Dockerfile
@@ -1,19 +1,12 @@
FROM golang:1.10 as builder
ADD . /go/src/github.com/hanakoa/alpaca
WORKDIR /go/src/github.com/hanakoa/alpaca/services/email
RUN go get ./... && \
CGO_ENABLED=0 GOOS=linux go build -a -o ./bin/alpaca-email .
# won't need to go get vgo in golang 1.11
RUN go get -u -v golang.org/x/vgo && \
CGO_ENABLED=0 GOOS=linux vgo build -a -o ./bin/alpaca-email .

FROM alpine:latest
#ENV ALPACA_USER="alpaca" \
# ALPACA_UID="8080" \
# ALPACA_GROUP="alpaca" \
# ALPACA_GID="8080"
RUN apk --no-cache add ca-certificates
#&& \
# addgroup -S -g $ALPACA_GID $ALPACA_GROUP && \
# adduser -S -u $ALPACA_UID -G $ALPACA_GROUP $ALPACA_USER
WORKDIR /root/
COPY --from=builder /go/src/github.com/hanakoa/alpaca/services/email/bin/alpaca-email .
#USER $ALPACA_USER
CMD ["./alpaca-email"]
13 changes: 3 additions & 10 deletions services/mfa/Dockerfile
@@ -1,19 +1,12 @@
FROM golang:1.10 as builder
ADD . /go/src/github.com/hanakoa/alpaca
WORKDIR /go/src/github.com/hanakoa/alpaca/services/mfa
RUN go get ./... && \
CGO_ENABLED=0 GOOS=linux go build -a -o ./bin/alpaca-mfa .
# won't need to go get vgo in golang 1.11
RUN go get -u -v golang.org/x/vgo && \
CGO_ENABLED=0 GOOS=linux vgo build -a -o ./bin/alpaca-mfa .

FROM alpine:latest
#ENV ALPACA_USER="alpaca" \
# ALPACA_UID="8080" \
# ALPACA_GROUP="alpaca" \
# ALPACA_GID="8080"
RUN apk --no-cache add ca-certificates
#&& \
# addgroup -S -g $ALPACA_GID $ALPACA_GROUP && \
# adduser -S -u $ALPACA_UID -G $ALPACA_GROUP $ALPACA_USER
WORKDIR /root/
COPY --from=builder /go/src/github.com/hanakoa/alpaca/services/mfa/bin/alpaca-mfa .
#USER $ALPACA_USER
CMD ["./alpaca-mfa"]
21 changes: 21 additions & 0 deletions services/mfa/go.mod
@@ -0,0 +1,21 @@
module github.com/hanakoa/alpaca/services/mfa

require (
github.com/TeslaGov/envy v0.0.1
github.com/bwmarrin/snowflake v0.0.0-20180412010544-68117e6bbede
github.com/dgrijalva/jwt-go v0.0.0-20180308231308-06ea1031745c
github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188
github.com/golang/protobuf v1.1.0
github.com/google/uuid v0.0.0-20171129191014-dec09d789f3d
github.com/gorilla/handlers v1.3.0
github.com/gorilla/mux v1.6.2
github.com/gorilla/schema v1.0.2
github.com/kevinmichaelchen/my-go-utils v0.0.1
github.com/lib/pq v0.0.0-20180523175426-90697d60dd84
github.com/sfreiberg/gotwilio v0.0.0-20180612161623-8fb7259ba8bf
github.com/streadway/amqp v0.0.0-20180528204448-e5adc2ada8b8
golang.org/x/net v0.0.0-20180702212446-ed29d75add3d
golang.org/x/text v0.3.0
google.golang.org/genproto v0.0.0-20180627194029-ff3583edef7d
google.golang.org/grpc v1.13.0
)
4 changes: 2 additions & 2 deletions services/mfa/main.go
Expand Up @@ -4,7 +4,7 @@ import (
"database/sql"
"fmt"
"github.com/TeslaGov/envy"
"github.com/hanakoa/alpaca/services/mfa/grpc"
mfaGRPC "github.com/hanakoa/alpaca/services/mfa/grpc"
"github.com/hanakoa/alpaca/services/mfa/services"
sqlUtils "github.com/kevinmichaelchen/my-go-utils/sql"
"github.com/sfreiberg/gotwilio"
Expand Down Expand Up @@ -48,7 +48,7 @@ func main() {
go a.ServeRest(fmt.Sprintf(":%d", port), origin)

wg.Add(1)
grpcServer := &grpc.GrpcServer{
grpcServer := &mfaGRPC.GrpcServer{
Port: grpcPort,
DB: db,
TwilioService: twilioService}
Expand Down
13 changes: 3 additions & 10 deletions services/password-reset/Dockerfile
@@ -1,19 +1,12 @@
FROM golang:1.10 as builder
ADD . /go/src/github.com/hanakoa/alpaca
WORKDIR /go/src/github.com/hanakoa/alpaca/services/password-reset
RUN go get ./... && \
CGO_ENABLED=0 GOOS=linux go build -a -o ./bin/alpaca-password-reset .
# won't need to go get vgo in golang 1.11
RUN go get -u -v golang.org/x/vgo && \
CGO_ENABLED=0 GOOS=linux vgo build -a -o ./bin/alpaca-password-reset .

FROM alpine:latest
#ENV ALPACA_USER="alpaca" \
# ALPACA_UID="8080" \
# ALPACA_GROUP="alpaca" \
# ALPACA_GID="8080"
RUN apk --no-cache add ca-certificates
#&& \
# addgroup -S -g $ALPACA_GID $ALPACA_GROUP && \
# adduser -S -u $ALPACA_UID -G $ALPACA_GROUP $ALPACA_USER
WORKDIR /root/
COPY --from=builder /go/src/github.com/hanakoa/alpaca/services/password-reset/bin/alpaca-password-reset .
#USER $ALPACA_USER
CMD ["./alpaca-password-reset"]
29 changes: 29 additions & 0 deletions services/password-reset/go.mod
@@ -0,0 +1,29 @@
module github.com/hanakoa/alpaca/services/password-reset

require (
github.com/TeslaGov/cursor v0.0.1
github.com/TeslaGov/envy v0.0.1
github.com/badoux/checkmail v0.0.0-20180430153108-0755fe2dc241
github.com/bwmarrin/snowflake v0.0.0-20180412010544-68117e6bbede
github.com/dgrijalva/jwt-go v0.0.0-20180308231308-06ea1031745c
github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188
github.com/golang/protobuf v1.1.0
github.com/google/uuid v0.0.0-20171129191014-dec09d789f3d
github.com/gorilla/handlers v1.3.0
github.com/gorilla/mux v1.6.2
github.com/gorilla/schema v1.0.2
github.com/hanakoa/alpaca v0.0.0-20180703023732-ac8f08ce0dab
github.com/kevinmichaelchen/my-go-utils v0.0.1
github.com/lib/pq v0.0.0-20180523175426-90697d60dd84
github.com/nbutton23/zxcvbn-go v0.0.0-20180510020640-780cc39d5c78
github.com/sfreiberg/gotwilio v0.0.0-20180612161623-8fb7259ba8bf
github.com/streadway/amqp v0.0.0-20180528204448-e5adc2ada8b8
github.com/ttacon/builder v0.0.0-20170518171403-c099f663e1c2
github.com/ttacon/libphonenumber v1.0.0
golang.org/x/crypto v0.0.0-20180621125126-a49355c7e3f8
golang.org/x/net v0.0.0-20180702212446-ed29d75add3d
golang.org/x/text v0.3.0
google.golang.org/genproto v0.0.0-20180627194029-ff3583edef7d
google.golang.org/grpc v1.13.0
gopkg.in/guregu/null.v3 v3.3.0
)

0 comments on commit 1681a44

Please sign in to comment.