mirror of
https://github.com/offen/website.git
synced 2024-11-26 02:40:26 +01:00
Merge pull request #30 from offen/dockerize-dev
Dockerize development environment
This commit is contained in:
commit
842c87c02a
@ -4,6 +4,8 @@ jobs:
|
|||||||
kms:
|
kms:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/golang:1.12
|
- image: circleci/golang:1.12
|
||||||
|
environment:
|
||||||
|
- PORT=8081
|
||||||
working_directory: ~/offen/kms
|
working_directory: ~/offen/kms
|
||||||
steps:
|
steps:
|
||||||
- checkout:
|
- checkout:
|
||||||
@ -29,6 +31,7 @@ jobs:
|
|||||||
- image: circleci/golang:1.12
|
- image: circleci/golang:1.12
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_CONNECTION_STRING=postgres://circle:test@localhost:5432/circle_test?sslmode=disable
|
- POSTGRES_CONNECTION_STRING=postgres://circle:test@localhost:5432/circle_test?sslmode=disable
|
||||||
|
- PORT=8080
|
||||||
- image: circleci/postgres:11.2-alpine
|
- image: circleci/postgres:11.2-alpine
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_USER=circle
|
- POSTGRES_USER=circle
|
||||||
|
25
Makefile
Normal file
25
Makefile
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
help:
|
||||||
|
@echo " setup"
|
||||||
|
@echo " Build the containers and install dependencies."
|
||||||
|
@echo " bootstrap"
|
||||||
|
@echo " Create a KMS key and initialize the database."
|
||||||
|
@echo " IMPORTANT: this wipes any existing data in your local database."
|
||||||
|
@echo " build"
|
||||||
|
@echo " Build all applications."
|
||||||
|
|
||||||
|
setup:
|
||||||
|
@docker-compose build
|
||||||
|
@docker-compose run script npm install
|
||||||
|
@docker-compose run vault npm install
|
||||||
|
@docker-compose run auditorium npm install
|
||||||
|
@docker-compose run server go mod download
|
||||||
|
@docker-compose run kms go mod download
|
||||||
|
@echo "Successfully built containers and installed dependencies."
|
||||||
|
@echo "If this is your initial setup, you can run 'make bootstrap' next"
|
||||||
|
@echo "to create the needed local keys and seed the database."
|
||||||
|
|
||||||
|
bootstrap:
|
||||||
|
@docker-compose run kms make bootstrap
|
||||||
|
@docker-compose run server make bootstrap
|
||||||
|
|
||||||
|
.PHONY: setup bootstrap
|
18
README.md
18
README.md
@ -16,13 +16,27 @@ Project planning and issue tracking is done using [Pivotal Tracker](https://www.
|
|||||||
|
|
||||||
### Developing the application
|
### Developing the application
|
||||||
|
|
||||||
You can test setup by starting the application:
|
The development setup requires `docker` and `docker-compose` to be installed.
|
||||||
|
|
||||||
|
After cloning the repository, you can build the containers and install dependencies using:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ make setup
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Next, create a local encryption key for the `kms` service and seed the database for the `server` application:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ make bootstrap
|
||||||
|
```
|
||||||
|
|
||||||
|
You can test your setup by starting the application:
|
||||||
|
|
||||||
|
```sh
|
||||||
$ docker-compose up
|
$ docker-compose up
|
||||||
```
|
```
|
||||||
|
|
||||||
Now you should be able to access <http://localhost:8080/status> seeing a successful response.
|
which should enable you to access <http://localhost:8080/status> seeing a successful response.
|
||||||
|
|
||||||
### License
|
### License
|
||||||
|
|
||||||
|
@ -1,47 +1,54 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
kms:
|
|
||||||
image: golang:1.12
|
|
||||||
working_dir: /code/kms
|
|
||||||
volumes:
|
|
||||||
- .:/code
|
|
||||||
- $GOPATH/pkg/mod:/go/pkg/mod
|
|
||||||
environment:
|
|
||||||
- GOPATH=/go
|
|
||||||
- KEY_FILE=key.txt
|
|
||||||
ports:
|
|
||||||
- 8081:8081
|
|
||||||
command: go run cmd/kms/main.go -port 8081 -origin http://localhost:9977
|
|
||||||
|
|
||||||
server:
|
|
||||||
image: golang:1.12
|
|
||||||
working_dir: /code/server
|
|
||||||
volumes:
|
|
||||||
- .:/code
|
|
||||||
- $GOPATH/pkg/mod:/go/pkg/mod
|
|
||||||
environment:
|
|
||||||
- GOPATH=/go
|
|
||||||
- POSTGRES_CONNECTION_STRING=postgres://postgres:develop@database:5432/postgres?sslmode=disable
|
|
||||||
- KMS_ENCRYPTION_ENDPOINT=http://kms:8081/encrypt
|
|
||||||
ports:
|
|
||||||
- 8080:8080
|
|
||||||
command: go run cmd/server/main.go -origin http://localhost:9977 -conn postgres://postgres:develop@database:5432/postgres?sslmode=disable -level debug
|
|
||||||
links:
|
|
||||||
- database
|
|
||||||
depends_on:
|
|
||||||
- kms
|
|
||||||
|
|
||||||
database:
|
database:
|
||||||
image: postgres:11.2
|
image: postgres:11.2
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_PASSWORD=develop
|
- POSTGRES_PASSWORD=develop
|
||||||
|
|
||||||
|
kms:
|
||||||
|
build:
|
||||||
|
context: '.'
|
||||||
|
dockerfile: Dockerfile.golang
|
||||||
|
working_dir: /offen/kms
|
||||||
|
volumes:
|
||||||
|
- .:/offen
|
||||||
|
- kmsdeps:/go/pkg/mod
|
||||||
|
environment:
|
||||||
|
- KEY_FILE=key.txt
|
||||||
|
- PORT=8081
|
||||||
|
ports:
|
||||||
|
- 8081:8081
|
||||||
|
command: refresh run
|
||||||
|
|
||||||
|
server:
|
||||||
|
build:
|
||||||
|
context: '.'
|
||||||
|
dockerfile: Dockerfile.golang
|
||||||
|
working_dir: /offen/server
|
||||||
|
volumes:
|
||||||
|
- .:/offen
|
||||||
|
- serverdeps:/go/pkg/mod
|
||||||
|
environment:
|
||||||
|
- POSTGRES_CONNECTION_STRING=postgres://postgres:develop@database:5432/postgres?sslmode=disable
|
||||||
|
- KMS_ENCRYPTION_ENDPOINT=http://kms:8081/encrypt
|
||||||
|
- PORT=8080
|
||||||
|
ports:
|
||||||
|
- 8080:8080
|
||||||
|
command: refresh run
|
||||||
|
links:
|
||||||
|
- database
|
||||||
|
depends_on:
|
||||||
|
- kms
|
||||||
|
|
||||||
vault:
|
vault:
|
||||||
image: timbru31/node-chrome:slim
|
build:
|
||||||
|
context: '.'
|
||||||
|
dockerfile: Dockerfile.node
|
||||||
working_dir: /offen/vault
|
working_dir: /offen/vault
|
||||||
volumes:
|
volumes:
|
||||||
- .:/offen
|
- .:/offen
|
||||||
|
- vaultdeps:/offen/vault/node_modules
|
||||||
command: npm start -- --port 9977
|
command: npm start -- --port 9977
|
||||||
ports:
|
ports:
|
||||||
- 9977:9977
|
- 9977:9977
|
||||||
@ -51,10 +58,13 @@ services:
|
|||||||
- AUDITORIUM_HOST=http://localhost:9955
|
- AUDITORIUM_HOST=http://localhost:9955
|
||||||
|
|
||||||
script:
|
script:
|
||||||
image: timbru31/node-chrome:slim
|
build:
|
||||||
|
context: '.'
|
||||||
|
dockerfile: Dockerfile.node
|
||||||
working_dir: /offen/script
|
working_dir: /offen/script
|
||||||
volumes:
|
volumes:
|
||||||
- .:/offen
|
- .:/offen
|
||||||
|
- scriptdeps:/offen/script/node_modules
|
||||||
command: npm start -- --port 9966
|
command: npm start -- --port 9966
|
||||||
ports:
|
ports:
|
||||||
- 9966:9966
|
- 9966:9966
|
||||||
@ -62,12 +72,22 @@ services:
|
|||||||
- VAULT_HOST=http://localhost:9977
|
- VAULT_HOST=http://localhost:9977
|
||||||
|
|
||||||
auditorium:
|
auditorium:
|
||||||
image: timbru31/node-chrome:slim
|
build:
|
||||||
|
context: '.'
|
||||||
|
dockerfile: Dockerfile.node
|
||||||
working_dir: /offen/auditorium
|
working_dir: /offen/auditorium
|
||||||
volumes:
|
volumes:
|
||||||
- .:/offen
|
- .:/offen
|
||||||
|
- auditoriumdeps_2:/offen/auditorium/node_modules
|
||||||
command: npm start -- --port 9955
|
command: npm start -- --port 9955
|
||||||
ports:
|
ports:
|
||||||
- 9955:9955
|
- 9955:9955
|
||||||
environment:
|
environment:
|
||||||
- VAULT_HOST=http://localhost:9977
|
- VAULT_HOST=http://localhost:9977
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
kmsdeps:
|
||||||
|
serverdeps:
|
||||||
|
scriptdeps:
|
||||||
|
auditoriumdeps_2:
|
||||||
|
vaultdeps:
|
||||||
|
Loading…
Reference in New Issue
Block a user