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

Commit

Permalink
repackaged
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmichaelchen committed Jul 2, 2018
1 parent ff65631 commit dfa71ff
Show file tree
Hide file tree
Showing 57 changed files with 69 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Expand Up @@ -73,7 +73,7 @@ jobs:
command: |
trap "go-junit-report <${TEST_RESULTS}/go-test.out > ${TEST_RESULTS}/go-test-report.xml" EXIT
touch /tmp/coverage.out
go test -cover -coverprofile=/tmp/coverage.out -v ./auth | tee ${TEST_RESULTS}/go-test.out
go test -cover -coverprofile=/tmp/coverage.out -v ./services/auth | tee ${TEST_RESULTS}/go-test.out
goveralls -coverprofile=/tmp/coverage.out -service=circle-ci -repotoken=$COVERALLS_TOKEN
- run: make build
Expand Down
10 changes: 6 additions & 4 deletions Makefile
@@ -1,3 +1,5 @@
SERVICES_DIR = ./services

.PHONY: all
all:
@$(MAKE) build
Expand Down Expand Up @@ -25,15 +27,15 @@ build:

.PHONY: build-auth
build-auth:
go build -o ./bin/alpaca-auth ./auth
go build -o ./bin/alpaca-auth $(SERVICES_DIR)/auth

.PHONY: build-password-reset
build-password-reset:
go build -o ./bin/alpaca-password-reset ./password-reset
go build -o ./bin/alpaca-password-reset $(SERVICES_DIR)/password-reset

.PHONY: build-mfa
build-mfa:
go build -o ./bin/alpaca-mfa ./mfa
go build -o ./bin/alpaca-mfa $(SERVICES_DIR)/mfa

.PHONY: run-auth
run-auth:
Expand Down Expand Up @@ -61,7 +63,7 @@ run-mfa:

.PHONY: test
test:
go test -v ./auth
go test -v $(SERVICES_DIR)/auth

.PHONY: convey
convey:
Expand Down
2 changes: 1 addition & 1 deletion docs/differences.md
Expand Up @@ -18,7 +18,7 @@

#### Insanely fast build times!
```bash
$ time go build -o ./bin/alpaca-auth ./auth
$ time go build -o ./bin/alpaca-auth ./services/auth
1.52s user 0.59s system 130% cpu 1.618 total
```

Expand Down
14 changes: 13 additions & 1 deletion docs/roadmap.md
@@ -1,2 +1,14 @@
- [ ] vgo #17
- [ ] set jwt cookie on successful response
- [ ] set jwt cookie on successful response

### better packaging
right now, we they're ~16mb
```bash
ls -la bin
total 91928
-rwxr-xr-x 1 kevinchen staff 16M Jul 2 10:18 alpaca-auth*
-rwxr-xr-x 1 kevinchen staff 13M Jul 2 10:18 alpaca-mfa*
-rwxr-xr-x 1 kevinchen staff 16M Jul 2 10:18 alpaca-password-reset*
```

if we package smarter, we might be able to reduce this size
12 changes: 6 additions & 6 deletions makefiles/code-quality.mk
@@ -1,14 +1,14 @@
.PHONY: lint
lint:
golint ./auth
golint ./password-reset
golint ./mfa
golint $(SERVICES_DIR)/auth
golint $(SERVICES_DIR)/password-reset
golint $(SERVICES_DIR)/mfa

.PHONY: fmt
fmt:
go fmt ./auth
go fmt ./password-reset
go fmt ./mfa
go fmt $(SERVICES_DIR)/auth
go fmt $(SERVICES_DIR)/password-reset
go fmt $(SERVICES_DIR)/mfa

.PHONY: vet
vet:
Expand Down
4 changes: 2 additions & 2 deletions makefiles/protobuf.mk
@@ -1,7 +1,7 @@
.PHONY: protoc
protoc:
protoc -I auth auth/pb/auth.proto --go_out=plugins=grpc:auth
protoc -I mfa mfa/pb/mfa.proto --go_out=plugins=grpc:mfa
protoc -I auth $(SERVICES_DIR)/auth/pb/auth.proto --go_out=plugins=grpc:auth
protoc -I mfa $(SERVICES_DIR)/mfa/pb/mfa.proto --go_out=plugins=grpc:mfa

.PHONY: install-proto
install-proto:
Expand Down
4 changes: 2 additions & 2 deletions auth/Dockerfile → services/auth/Dockerfile
@@ -1,6 +1,6 @@
FROM golang:1.10 as builder
ADD . /go/src/github.com/hanakoa/alpaca
WORKDIR /go/src/github.com/hanakoa/alpaca/auth
WORKDIR /go/src/github.com/hanakoa/alpaca/services/auth
RUN go get ./... && \
CGO_ENABLED=0 GOOS=linux go build -a -o ./bin/alpaca-auth .

Expand All @@ -14,6 +14,6 @@ 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/auth/bin/alpaca-auth .
COPY --from=builder /go/src/github.com/hanakoa/alpaca/services/auth/bin/alpaca-auth .
#USER $ALPACA_USER
CMD ["./alpaca-auth"]
File renamed without changes.
4 changes: 2 additions & 2 deletions auth/app.go → services/auth/app.go
Expand Up @@ -5,8 +5,8 @@ import (
"github.com/bwmarrin/snowflake"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"github.com/hanakoa/alpaca/auth/services"
mfaGRPC "github.com/hanakoa/alpaca/mfa/grpc"
"github.com/hanakoa/alpaca/services/auth/services"
mfaGRPC "github.com/hanakoa/alpaca/services/mfa/grpc"
"github.com/kevinmichaelchen/my-go-utils/rabbitmq"
_ "github.com/lib/pq"
"log"
Expand Down
File renamed without changes.
Expand Up @@ -2,7 +2,7 @@ package grpc

import (
"golang.org/x/net/context"
pb "github.com/hanakoa/alpaca/auth/pb"
pb "github.com/hanakoa/alpaca/services/auth/pb"
"fmt"
grpcUtils "github.com/kevinmichaelchen/my-go-utils/grpc"
"time"
Expand Down
Expand Up @@ -3,14 +3,14 @@ package grpc
import (
"fmt"
"log"
pb "github.com/hanakoa/alpaca/auth/pb"
pb "github.com/hanakoa/alpaca/services/auth/pb"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
"net"
"database/sql"
"github.com/hanakoa/alpaca/auth/models"
"github.com/hanakoa/alpaca/auth/services"
"github.com/hanakoa/alpaca/services/auth/models"
"github.com/hanakoa/alpaca/services/auth/services"
"gopkg.in/guregu/null.v3"
)

Expand Down
6 changes: 3 additions & 3 deletions auth/main.go → services/auth/main.go
Expand Up @@ -4,9 +4,9 @@ import (
"database/sql"
"fmt"
"github.com/TeslaGov/envy"
"github.com/hanakoa/alpaca/auth/grpc"
"github.com/hanakoa/alpaca/auth/models"
mfaGRPC "github.com/hanakoa/alpaca/mfa/grpc"
"github.com/hanakoa/alpaca/services/auth/grpc"
"github.com/hanakoa/alpaca/services/auth/models"
mfaGRPC "github.com/hanakoa/alpaca/services/mfa/grpc"
snowflakeUtils "github.com/kevinmichaelchen/my-go-utils/snowflake"
sqlUtils "github.com/kevinmichaelchen/my-go-utils/sql"
"log"
Expand Down
4 changes: 2 additions & 2 deletions auth/main_test.go → services/auth/main_test.go
Expand Up @@ -6,8 +6,8 @@ import (
"encoding/json"
"fmt"
"github.com/TeslaGov/envy"
"github.com/hanakoa/alpaca/auth/models"
"github.com/hanakoa/alpaca/auth/services"
"github.com/hanakoa/alpaca/services/auth/models"
"github.com/hanakoa/alpaca/services/auth/services"
snowflakeUtils "github.com/kevinmichaelchen/my-go-utils/snowflake"
stringUtils "github.com/kevinmichaelchen/my-go-utils/string"
. "github.com/smartystreets/goconvey/convey"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -7,7 +7,7 @@ import (
sqlUtils "github.com/kevinmichaelchen/my-go-utils/sql"
snowflakeUtils "github.com/kevinmichaelchen/my-go-utils/snowflake"
"github.com/gorilla/mux"
"github.com/hanakoa/alpaca/auth/models"
"github.com/hanakoa/alpaca/services/auth/models"
"gopkg.in/guregu/null.v3"
"time"
"strconv"
Expand Down
2 changes: 1 addition & 1 deletion auth/services/mfa.go → services/auth/services/mfa.go
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/google/uuid"
"log"
requestUtils "github.com/kevinmichaelchen/my-go-utils/request"
"github.com/hanakoa/alpaca/auth/models"
"github.com/hanakoa/alpaca/services/auth/models"
)

type LoginResponse struct {
Expand Down
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/bwmarrin/snowflake"
"net/http"
"github.com/gorilla/mux"
"github.com/hanakoa/alpaca/auth/models"
"github.com/hanakoa/alpaca/services/auth/models"
"encoding/json"
requestUtils "github.com/kevinmichaelchen/my-go-utils/request"
snowflakeUtils "github.com/kevinmichaelchen/my-go-utils/snowflake"
Expand Down
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"
"github.com/gorilla/mux"
"strconv"
"github.com/hanakoa/alpaca/auth/models"
"github.com/hanakoa/alpaca/services/auth/models"
"encoding/json"
"github.com/bwmarrin/snowflake"
"time"
Expand Down
4 changes: 2 additions & 2 deletions auth/services/token.go → services/auth/services/token.go
Expand Up @@ -6,12 +6,12 @@ import (
"net/http"
requestUtils "github.com/kevinmichaelchen/my-go-utils/request"
snowflakeUtils "github.com/kevinmichaelchen/my-go-utils/snowflake"
mfaGRPC "github.com/hanakoa/alpaca/mfa/grpc"
mfaGRPC "github.com/hanakoa/alpaca/services/mfa/grpc"
"encoding/json"
"gopkg.in/guregu/null.v3"
"strings"
"time"
"github.com/hanakoa/alpaca/auth/models"
"github.com/hanakoa/alpaca/services/auth/models"
"log"
"github.com/badoux/checkmail"
"fmt"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions email/Dockerfile → services/email/Dockerfile
@@ -1,6 +1,6 @@
FROM golang:1.10 as builder
ADD . /go/src/github.com/hanakoa/alpaca
WORKDIR /go/src/github.com/hanakoa/alpaca/email
WORKDIR /go/src/github.com/hanakoa/alpaca/services/email
RUN go get ./... && \
CGO_ENABLED=0 GOOS=linux go build -a -o ./bin/alpaca-email .

Expand All @@ -14,6 +14,6 @@ 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/email/bin/alpaca-email .
COPY --from=builder /go/src/github.com/hanakoa/alpaca/services/email/bin/alpaca-email .
#USER $ALPACA_USER
CMD ["./alpaca-email"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions mfa/Dockerfile → services/mfa/Dockerfile
@@ -1,6 +1,6 @@
FROM golang:1.10 as builder
ADD . /go/src/github.com/hanakoa/alpaca
WORKDIR /go/src/github.com/hanakoa/alpaca/mfa
WORKDIR /go/src/github.com/hanakoa/alpaca/services/mfa
RUN go get ./... && \
CGO_ENABLED=0 GOOS=linux go build -a -o ./bin/alpaca-mfa .

Expand All @@ -14,6 +14,6 @@ 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/mfa/bin/alpaca-mfa .
COPY --from=builder /go/src/github.com/hanakoa/alpaca/services/mfa/bin/alpaca-mfa .
#USER $ALPACA_USER
CMD ["./alpaca-mfa"]
File renamed without changes.
2 changes: 1 addition & 1 deletion mfa/app.go → services/mfa/app.go
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/bwmarrin/snowflake"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"github.com/hanakoa/alpaca/mfa/services"
"github.com/hanakoa/alpaca/services/mfa/services"
"github.com/kevinmichaelchen/my-go-utils/rabbitmq"
snowflakeUtils "github.com/kevinmichaelchen/my-go-utils/snowflake"
_ "github.com/lib/pq"
Expand Down
Expand Up @@ -2,7 +2,7 @@ package grpc

import (
"golang.org/x/net/context"
pb "github.com/hanakoa/alpaca/mfa/pb"
pb "github.com/hanakoa/alpaca/services/mfa/pb"
"fmt"
grpcUtils "github.com/kevinmichaelchen/my-go-utils/grpc"
"time"
Expand Down
6 changes: 3 additions & 3 deletions mfa/grpc/grpc_server.go → services/mfa/grpc/grpc_server.go
Expand Up @@ -7,13 +7,13 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
"golang.org/x/net/context"
pb "github.com/hanakoa/alpaca/mfa/pb"
"github.com/hanakoa/alpaca/mfa/models"
pb "github.com/hanakoa/alpaca/services/mfa/pb"
"github.com/hanakoa/alpaca/services/mfa/models"
"database/sql"
"github.com/google/uuid"
"time"
"math/rand"
"github.com/hanakoa/alpaca/mfa/services"
"github.com/hanakoa/alpaca/services/mfa/services"
)

type GrpcServer struct {
Expand Down
4 changes: 2 additions & 2 deletions mfa/main.go → services/mfa/main.go
Expand Up @@ -4,8 +4,8 @@ import (
"database/sql"
"fmt"
"github.com/TeslaGov/envy"
"github.com/hanakoa/alpaca/mfa/grpc"
"github.com/hanakoa/alpaca/mfa/services"
"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"
"log"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,6 +1,6 @@
FROM golang:1.10 as builder
ADD . /go/src/github.com/hanakoa/alpaca
WORKDIR /go/src/github.com/hanakoa/alpaca/password-reset
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 .

Expand All @@ -14,6 +14,6 @@ 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/password-reset/bin/alpaca-password-reset .
COPY --from=builder /go/src/github.com/hanakoa/alpaca/services/password-reset/bin/alpaca-password-reset .
#USER $ALPACA_USER
CMD ["./alpaca-password-reset"]
File renamed without changes.
4 changes: 2 additions & 2 deletions password-reset/app.go → services/password-reset/app.go
Expand Up @@ -5,8 +5,8 @@ import (
"github.com/bwmarrin/snowflake"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
authGRPC "github.com/hanakoa/alpaca/auth/grpc"
"github.com/hanakoa/alpaca/password-reset/services"
authGRPC "github.com/hanakoa/alpaca/services/auth/grpc"
"github.com/hanakoa/alpaca/services/password-reset/services"
"github.com/kevinmichaelchen/my-go-utils/rabbitmq"
snowflakeUtils "github.com/kevinmichaelchen/my-go-utils/snowflake"
_ "github.com/lib/pq"
Expand Down
2 changes: 1 addition & 1 deletion password-reset/main.go → services/password-reset/main.go
Expand Up @@ -4,7 +4,7 @@ import (
"database/sql"
"fmt"
"github.com/TeslaGov/envy"
authGRPC "github.com/hanakoa/alpaca/auth/grpc"
authGRPC "github.com/hanakoa/alpaca/services/auth/grpc"
sqlUtils "github.com/kevinmichaelchen/my-go-utils/sql"
"log"
"sync"
Expand Down
Expand Up @@ -5,7 +5,7 @@ import (
"database/sql"
"encoding/json"
"github.com/TeslaGov/envy"
"github.com/hanakoa/alpaca/password-reset/services"
"github.com/hanakoa/alpaca/services/password-reset/services"
. "github.com/smartystreets/goconvey/convey"
"net/http"
"net/http/httptest"
Expand Down
File renamed without changes.
Expand Up @@ -11,7 +11,7 @@ import (
"time"
"encoding/json"
"net/http"
"github.com/hanakoa/alpaca/password-reset/models"
"github.com/hanakoa/alpaca/services/password-reset/models"
"github.com/ttacon/libphonenumber"
)

Expand Down
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/badoux/checkmail"
"fmt"
"github.com/google/uuid"
authGRPC "github.com/hanakoa/alpaca/auth/grpc"
"github.com/hanakoa/alpaca/password-reset/models"
authGRPC "github.com/hanakoa/alpaca/services/auth/grpc"
"github.com/hanakoa/alpaca/services/password-reset/models"
)

type PasswordResetSvc struct {
Expand Down
File renamed without changes.
Expand Up @@ -6,7 +6,7 @@ import (
requestUtils "github.com/kevinmichaelchen/my-go-utils/request"
"fmt"
"net/http"
"github.com/hanakoa/alpaca/password-reset/models"
"github.com/hanakoa/alpaca/services/password-reset/models"
"github.com/google/uuid"
)

Expand Down

0 comments on commit dfa71ff

Please sign in to comment.