-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from imulab/features/build
Features/build
- Loading branch information
Showing
11 changed files
with
256 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
########################################################################## | ||
# GO BUILDER | ||
########################################################################## | ||
FROM golang:1.13-buster AS builder | ||
|
||
WORKDIR /build/scim | ||
|
||
COPY . ./ | ||
|
||
RUN make build | ||
|
||
########################################################################## | ||
# FINAL IMAGE | ||
########################################################################## | ||
FROM debian:buster-slim | ||
|
||
# copy binary | ||
COPY --from=builder /build/scim/bin/linux_amd64/scim /usr/bin/scim | ||
|
||
# copy public files | ||
COPY --from=builder /build/scim/public /usr/share/scim/public | ||
|
||
# run | ||
CMD ["/usr/bin/scim"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
.PHONY: all build deps binary test doc | ||
|
||
OK_COLOR=\033[32;01m | ||
NO_COLOR=\033[0m | ||
ERROR_COLOR=\033[31;01m | ||
WARN_COLOR=\033[33;01m | ||
|
||
NOW = $(shell date -u '+%Y%m%d%I%M%S') | ||
|
||
DOCKER := docker | ||
GO := go | ||
GO_ENV := $(shell $(GO) env GOOS GOARCH) | ||
GOOS ?= $(word 1,$(GO_ENV)) | ||
GOARCH ?= $(word 2,$(GO_ENV)) | ||
GOFLAGS ?= $(GOFLAGS:) | ||
ROOT_DIR := $(realpath .) | ||
|
||
# GOOS/GOARCH of the build host, used to determine whether we're cross-compiling or not | ||
BUILDER_GOOS_GOARCH="$(GOOS)_$(GOARCH)" | ||
|
||
ifneq ($(GOOS), darwin) | ||
EXTLDFLAGS = # EXTLDFLAGS = -extldflags "-lm -lstdc++ -static" | ||
else | ||
EXTLDFLAGS = | ||
endif | ||
|
||
GO_LINKER_FLAGS ?= --ldflags \ | ||
'$(EXTLDFLAGS) -s -w ' | ||
|
||
all: build | ||
|
||
build: deps binary | ||
|
||
deps: | ||
@echo "$(OK_COLOR)==> Fetching dependencies...$(NO_COLOR)" | ||
$(GO) mod download | ||
|
||
binary: | ||
@echo "$(OK_COLOR)==> Building binary ($(GOOS)/$(GOARCH))...$(NO_COLOR)" | ||
$(GO) build -a $(GOFLAGS) $(GO_LINKER_FLAGS) -o bin/$(GOOS)_$(GOARCH)/scim | ||
|
||
test: deps | ||
@echo "$(OK_COLOR)==> Running tests...$(NO_COLOR)" | ||
$(GO) test $(GOFLAGS) -race ./... | ||
|
||
doc: | ||
mkdir -p /tmp/tmpgoroot/doc | ||
rm -rf /tmp/tmpgopath/src/github.com/imulab/go-scim | ||
mkdir -p /tmp/tmpgopath/src/github.com/imulab/go-scim | ||
tar -c --exclude='.git' --exclude='tmp' . | tar -x -C /tmp/tmpgopath/src/github.com/imulab/go-scim | ||
@echo "$(OK_COLOR)==> Open http://localhost:6060/pkg/github.com/imulab/go-scim$(NO_COLOR)" | ||
GOROOT=/tmp/tmpgoroot/ GOPATH=/tmp/tmpgopath/ godoc -http=localhost:6060 | ||
|
||
docker: | ||
@echo "$(OK_COLOR)==> Building image scim:latest$(NO_COLOR)" | ||
docker build -t scim:latest . | ||
|
||
compose: | ||
@echo "$(OK_COLOR)==> Starting local stack$(NO_COLOR)" | ||
docker-compose up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,22 @@ | ||
package groupsync | ||
|
||
import "github.com/streadway/amqp" | ||
|
||
// Queue name in RabbitMQ, used by consumer and producer to exchange message. | ||
const RabbitQueueName = "group_sync" | ||
|
||
// Exchange name in RabbitMQ | ||
const RabbitExchangeName = "" | ||
|
||
// Declare a queue in RabbitMQ named RabbitQueueName. | ||
func DeclareQueue(ch *amqp.Channel) error { | ||
_, err := ch.QueueDeclare( | ||
RabbitQueueName, | ||
true, | ||
false, | ||
false, | ||
false, | ||
nil, | ||
) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
version: "3" | ||
services: | ||
mediainit: | ||
image: alpine:3.10 | ||
entrypoint: /bin/sh -c "chown -v nobody:nogroup /data/db && chmod -v 777 /data/db" | ||
container_name: mediainit | ||
restart: "no" | ||
volumes: | ||
- 'mongo_data:/data/db' | ||
|
||
db: | ||
image: "bitnami/mongodb:latest" | ||
environment: | ||
- MONGODB_EXTRA_FLAGS=--wiredTigerCacheSizeGB=2 --bind_ip_all | ||
- MONGODB_USERNAME=user | ||
- MONGODB_PASSWORD=password123 | ||
- MONGODB_DATABASE=scim_database | ||
volumes: | ||
- 'mongo_data:/data/db' | ||
ports: | ||
- '27017:27017' | ||
networks: | ||
- app-tier | ||
|
||
rabbit: | ||
image: "bitnami/rabbitmq:latest" | ||
environment: | ||
- RABBITMQ_USERNAME=user | ||
- RABBITMQ_PASSWORD=password123 | ||
- RABBITMQ_NODE_NAME=user@rabbit | ||
ports: | ||
- '4369:4369' | ||
- '5672:5672' | ||
- '25672:25672' | ||
- '15672:15672' | ||
networks: | ||
- app-tier | ||
volumes: | ||
- 'rabbitmq_data:/bitnami' | ||
|
||
group: | ||
image: "scim:latest" | ||
build: | ||
context: . | ||
command: ["/usr/bin/scim", "group-sync"] | ||
environment: | ||
- REQUEUE_LIMIT=1 | ||
- MONGO_HOST=db | ||
- MONGO_PORT=27017 | ||
- MONGO_USERNAME=user | ||
- MONGO_PASSWORD=password123 | ||
- MONGO_DATABASE=scim_database | ||
- MONGO_OPT=authMechanism=SCRAM-SHA-1 | ||
- RABBIT_HOST=rabbit | ||
- RABBIT_PORT=5672 | ||
- RABBIT_USERNAME=user | ||
- RABBIT_PASSWORD=password123 | ||
- SERVICE_PROVIDER_CONFIG=/usr/share/scim/public/service_provider_config.json | ||
- SCHEMAS_DIR=/usr/share/scim/public/schemas | ||
- USER_RESOURCE_TYPE=/usr/share/scim/public/resource_types/user_resource_type.json | ||
- GROUP_RESOURCE_TYPE=/usr/share/scim/public/resource_types/group_resource_type.json | ||
- MONGO_METADATA_DIR=/usr/share/scim/public/mongo_metadata | ||
networks: | ||
- app-tier | ||
depends_on: | ||
- db | ||
- rabbit | ||
|
||
server: | ||
image: "scim:latest" | ||
build: | ||
context: . | ||
command: ["/usr/bin/scim", "api"] | ||
environment: | ||
- HTTP_PORT=5000 | ||
- MONGO_HOST=db | ||
- MONGO_PORT=27017 | ||
- MONGO_USERNAME=user | ||
- MONGO_PASSWORD=password123 | ||
- MONGO_DATABASE=scim_database | ||
- MONGO_OPT=authMechanism=SCRAM-SHA-1 | ||
- RABBIT_HOST=rabbit | ||
- RABBIT_PORT=5672 | ||
- RABBIT_USERNAME=user | ||
- RABBIT_PASSWORD=password123 | ||
- SERVICE_PROVIDER_CONFIG=/usr/share/scim/public/service_provider_config.json | ||
- SCHEMAS_DIR=/usr/share/scim/public/schemas | ||
- USER_RESOURCE_TYPE=/usr/share/scim/public/resource_types/user_resource_type.json | ||
- GROUP_RESOURCE_TYPE=/usr/share/scim/public/resource_types/group_resource_type.json | ||
- MONGO_METADATA_DIR=/usr/share/scim/public/mongo_metadata | ||
ports: | ||
- "5000:5000" | ||
networks: | ||
- app-tier | ||
depends_on: | ||
- db | ||
- rabbit | ||
|
||
volumes: | ||
rabbitmq_data: | ||
driver: local | ||
mongo_data: | ||
driver: local | ||
|
||
networks: | ||
app-tier: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.