Set up a development environment with docker

Signed-off-by: Konstantinos Sideris <sideris.konstantin@gmail.com>
This commit is contained in:
Konstantinos Sideris 2017-12-24 19:34:30 +02:00
parent fa362ecef2
commit 5291e341c4
16 changed files with 308 additions and 0 deletions

5
.gitignore vendored
View file

@ -34,3 +34,8 @@ _testmain.go
*.exe
*.test
*.prof
# Generated keys
*.pem
*.key
*.crt

10
Dockerfile Normal file
View file

@ -0,0 +1,10 @@
FROM golang:alpine3.6
RUN mkdir /build
WORKDIR /build
RUN apk --update --no-cache add openssl bash git && \
go get github.com/constabulary/gb/...
CMD ["bash", "docker/build.sh"]

211
docker-compose.yml Normal file
View file

@ -0,0 +1,211 @@
version: "3.4"
services:
monolith:
container_name: dendrite_monolith
hostname: monolith
entrypoint: ["bash", "./docker/services/monolith.sh"]
build: ./
volumes:
- type: bind
source: ./
target: /build
networks:
- internal
depends_on:
- postgres
ports:
- "8008:8008"
- "8448:8448"
client_api_proxy:
container_name: dendrite_client_api_proxy
hostname: client_api_proxy
entrypoint: ["bash", "./docker/services/client-api-proxy.sh"]
build: ./
volumes:
- type: bind
source: ./
target: /build
networks:
- internal
depends_on:
- postgres
- sync_api
- client_api
- media_api
- public_rooms_api
ports:
- "8008:8008"
client_api:
container_name: dendrite_client_api
hostname: client_api
entrypoint: ["bash", "./docker/services/client-api.sh"]
build: ./
volumes:
- type: bind
source: ./
target: /build
depends_on:
- postgres
- room_server
networks:
- internal
ports:
- 7771
media_api:
container_name: dendrite_media_api
hostname: media_api
entrypoint: ["bash", "./docker/services/media-api.sh"]
build: ./
volumes:
- type: bind
source: ./
target: /build
depends_on:
- postgres
networks:
- internal
ports:
- 7774
public_rooms_api:
container_name: dendrite_public_rooms_api
hostname: public_rooms_api
entrypoint: ["bash", "./docker/services/public-rooms-api.sh"]
build: ./
volumes:
- type: bind
source: ./
target: /build
depends_on:
- postgres
networks:
- internal
ports:
- 7775
sync_api:
container_name: dendrite_sync_api
hostname: sync_api
entrypoint: ["bash", "./docker/services/sync-api.sh"]
build: ./
volumes:
- type: bind
source: ./
target: /build
depends_on:
- postgres
networks:
- internal
ports:
- 7773
room_server:
container_name: dendrite_room_server
hostname: room_server
entrypoint: ["bash", "./docker/services/room-server.sh"]
build: ./
volumes:
- type: bind
source: ./
target: /build
depends_on:
- postgres
networks:
- internal
ports:
- 7770
federation_api_proxy:
container_name: dendrite_federation_api_proxy
hostname: federation_api_proxy
entrypoint: ["bash", "./docker/services/federation-api-proxy.sh"]
build: ./
volumes:
- type: bind
source: ./
target: /build
depends_on:
- postgres
- federation_api
- federation_sender
- media_api
networks:
- internal
ports:
- "8448:8448"
federation_api:
container_name: dendrite_federation_api
hostname: federation_api
entrypoint: ["bash", "./docker/services/federation-api.sh"]
build: ./
volumes:
- type: bind
source: ./
target: /build
depends_on:
- postgres
networks:
- internal
ports:
- 7772
federation_sender:
container_name: dendrite_federation_sender
hostname: federation_sender
entrypoint: ["bash", "./docker/services/federation-sender.sh"]
build: ./
volumes:
- type: bind
source: ./
target: /build
depends_on:
- postgres
networks:
- internal
ports:
- 7776
postgres:
container_name: dendrite_postgres
hostname: postgres
build: ./docker/postgres
restart: always
environment:
POSTGRES_PASSWORD: itsasecret
POSTGRES_USER: dendrite
ports:
- 5432
networks:
- internal
zookeeper:
container_name: dendrite_zk
hostname: zookeeper
image: zookeeper
ports:
- 2181
networks:
- internal
kafka:
container_name: dendrite_kafka
hostname: kafka
image: wurstmeister/kafka
environment:
KAFKA_ADVERTISED_HOST_NAME: "kafka"
KAFKA_DELETE_TOPIC_ENABLE: "true"
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
depends_on:
- zookeeper
ports:
- 9092
networks:
- internal
networks:
internal:
attachable: true

18
docker/build.sh Normal file
View file

@ -0,0 +1,18 @@
#!/bin/bash
gb build
# Generate the keys if they don't already exist.
if [ ! -f server.key ] || [ ! -f server.crt ] || [ ! -f matrix_key.pem ]; then
echo "Generating keys ..."
rm -f server.key server.crt matrix_key.pem
test -f server.key || openssl req -x509 -newkey rsa:4096 \
-keyout server.key \
-out server.crt \
-days 3650 -nodes \
-subj /CN=localhost
test -f matrix_key.pem || /build/bin/generate-keys -private-key matrix_key.pem
fi

View file

@ -0,0 +1,3 @@
FROM postgres:9.5
COPY ./create_db.sh /docker-entrypoint-initdb.d/20-create_db.sh

View file

@ -0,0 +1,5 @@
#!/bin/bash
for db in account device mediaapi syncapi roomserver serverkey federationsender publicroomsapi naffka; do
createdb -O dendrite dendrite_$db
done

View file

@ -0,0 +1,9 @@
#!/bin/bash
bash ./docker/build.sh
./bin/client-api-proxy --bind-address ":8008" \
--client-api-server-url "http://client_api:7771" \
--sync-api-server-url "http://sync_api:7773" \
--media-api-server-url "http://media_api:7774" \
--public-rooms-api-server-url "http://public_rooms_api:7775" \

View file

@ -0,0 +1,5 @@
#!/bin/bash
bash ./docker/build.sh
./bin/dendrite-client-api-server --config=dendrite.yaml

View file

@ -0,0 +1,7 @@
#!/bin/bash
bash ./docker/build.sh
./bin/federation-api-proxy --bind-address ":8448" \
--federation-api-url "http://federation_api_server:7772" \
--media-api-server-url "http://media_api:7774" \

View file

@ -0,0 +1,5 @@
#!/bin/bash
bash ./docker/build.sh
./bin/dendrite-federation-api-server --config dendrite.yaml

View file

@ -0,0 +1,5 @@
#!/bin/bash
bash ./docker/build.sh
./bin/dendrite-federation-sender-server --config dendrite.yaml

View file

@ -0,0 +1,5 @@
#!/bin/bash
bash ./docker/build.sh
./bin/dendrite-media-api-server --config dendrite.yaml

View file

@ -0,0 +1,5 @@
#!/bin/bash
bash ./docker/build.sh
./bin/dendrite-monolith-server --tls-cert=server.crt --tls-key=server.key

View file

@ -0,0 +1,5 @@
#!/bin/bash
bash ./docker/build.sh
./bin/dendrite-public-rooms-api-server --config dendrite.yaml

View file

@ -0,0 +1,5 @@
#!/bin/bash
bash ./docker/build.sh
./bin/dendrite-room-server --config=dendrite.yaml

View file

@ -0,0 +1,5 @@
#!/bin/bash
bash ./docker/build.sh
./bin/dendrite-sync-api-server --config=dendrite.yaml