Skip to content
Permalink
Browse files

feat: add keycloak service

  • Loading branch information...
moul committed Jul 11, 2019
1 parent 77e28a5 commit 7f865f5d53b231eb89aad10ffc05f9f6e0d335b4
Showing with 85 additions and 30 deletions.
  1. +23 −15 Makefile
  2. +62 −15 docker-compose.yml
@@ -40,34 +40,42 @@ help:
sed 's/^/ $(HELP_MSG_PREFIX)make /'

.PHONY: run
run: $(BIN) mysql.up
run: $(BIN) serverdb.up
$(BIN) server $(RUN_OPTS)

.PHONY: install
install: $(BIN)
$(BIN): .proto.generated $(PWCTL_OUT_FILES) $(OUR_SOURCES)
go install -mod=readonly -v
go install -v

.PHONY: mysql.up
mysql.up:
docker-compose up -d mysql
@echo "Waiting for mysql to be ready..."
.PHONY: serverdb.up
serverdb.up:
docker-compose up -d serverdb
@echo "Waiting for serverdb to be ready..."
@while ! mysqladmin ping -h127.0.0.1 -P3306 --silent; do sleep 1; done
@echo "Done."

.PHONY: mysql.down
mysql.down:
docker-compose stop mysql || true
docker-compose rm -f -v mysql || true
.PHONY: serverdb.down
serverdb.down:
docker-compose stop serverdb || true
docker-compose rm -f -v serverdb || true

.PHONY: mysql.shell
mysql.shell:
.PHONY: serverdb.shell
serverdb.shell:
mysql -h127.0.0.1 -P3306 -uroot -puns3cur3 pathwar

.PHONY: mysql.dump
mysql.dump:
.PHONY: serverdb.dump
serverdb.dump:
mysqldump -h127.0.0.1 -P3306 -uroot -puns3cur3 pathwar

.PHONY: keycloakdb.shell
keycloakdb.shell:
mysql -h127.0.0.1 -P3307 -uroot -puns3cur3 keycloak

.PHONY: keycloakdb.dump
keycloakdb.dump:
mysqldump -h127.0.0.1 -P3307 -uroot -puns3cur3 keycloak

.PHONY: clean
clean:
rm -f $(GENERATED_FILES) .proto.generated
@@ -136,7 +144,7 @@ integration.build:
.PHONY:integration.run
integration.run:
docker-compose up -d --no-build server
docker-compose exec server ./wait-for-it.sh mysql:3306 -- echo mysql ready
docker-compose exec server ./wait-for-it.sh serverdb:3306 -- echo serverdb ready
docker-compose exec server ./wait-for-it.sh localhost:9111 -- echo gRPC ready
sleep 5
docker-compose exec server pathwar.pw sql adduser --sql-config=$$SQL_CONFIG --email=integration@example.com --username=integration --password=integration
@@ -1,43 +1,90 @@
version: '2.3'
version: '3.3'

services:
server:
image: pathwar/pathwar:latest
build: .
entrypoint:
- ./wait-for-it.sh
- mysql:3306
- server-db:3306
- "--"
environment:
- SQL_CONFIG=root:uns3cur3@tcp(mysql:3306)/pathwar?charset=utf8&parseTime=true
- SQL_CONFIG=pathwar:uns3cur3@tcp(serverdb:3306)/pathwar?charset=utf8&parseTime=true
command:
- /bin/pathwar.pw
- server
- --http-bind=0.0.0.0:8000
- --grpc-bind=0.0.0.0:9111
depends_on:
- mysql
- serverdb
- mailserver
ports:
- 8000:8000
- 9111:9111

mysql:
image: mysql:latest
command: --default-authentication-plugin=mysql_native_password
restart: always
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: uns3cur3
MYSQL_DATABASE: pathwar

web:
build: web
image: pathwar/pathwar:web
ports:
- 3000:3000
- 3001:3001
environment:
- NODE_ENV=development
- API_TARGET=server:8000
links:
- server
- server

keycloak:
image: jboss/keycloak:6.0.1
restart: always
environment:
KEYCLOAK_USER: admin
KEYCLOAK_PASSWORD: uns3cur3
DB_VENDOR: MYSQL
DB_ADDR: keycloakdb
DB_DATABASE: keycloak
DB_USER: root
DB_PASSWORD: uns3cur3
ports:
- 8443:8443
depends_on:
- keycloakdb
- mailserver

serverdb:
image: mariadb:10
restart: always
volumes:
- serverdb_data:/var/lib/mysql
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: uns3cur3
MYSQL_DATABASE: pathwar
MYSQL_USER: pathwar
MYSQL_PASSWORD: uns3cur3

keycloakdb:
image: mariadb:10
restart: always
volumes:
- keycloakdb_data:/var/lib/mysql
ports:
- 3307:3306
environment:
MYSQL_ROOT_PASSWORD: uns3cur3
MYSQL_DATABASE: keycloak
MYSQL_USER: keycloak
MYSQL_PASSWORD: uns3cur3

mailserver:
image: mailhog/mailhog
ports:
- 1025:1025
- 8025:8025

volumes:
serverdb_data:
driver: local
keycloakdb_data:
driver: local

0 comments on commit 7f865f5

Please sign in to comment.
You can’t perform that action at this time.