mirror of
https://github.com/offen/website.git
synced 2024-11-22 09:00:28 +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:
|
||||
docker:
|
||||
- image: circleci/golang:1.12
|
||||
environment:
|
||||
- PORT=8081
|
||||
working_directory: ~/offen/kms
|
||||
steps:
|
||||
- checkout:
|
||||
@ -29,6 +31,7 @@ jobs:
|
||||
- image: circleci/golang:1.12
|
||||
environment:
|
||||
- POSTGRES_CONNECTION_STRING=postgres://circle:test@localhost:5432/circle_test?sslmode=disable
|
||||
- PORT=8080
|
||||
- image: circleci/postgres:11.2-alpine
|
||||
environment:
|
||||
- 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
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
|
@ -1,47 +1,54 @@
|
||||
version: '3'
|
||||
|
||||
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:
|
||||
image: postgres:11.2
|
||||
environment:
|
||||
- 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:
|
||||
image: timbru31/node-chrome:slim
|
||||
build:
|
||||
context: '.'
|
||||
dockerfile: Dockerfile.node
|
||||
working_dir: /offen/vault
|
||||
volumes:
|
||||
- .:/offen
|
||||
- vaultdeps:/offen/vault/node_modules
|
||||
command: npm start -- --port 9977
|
||||
ports:
|
||||
- 9977:9977
|
||||
@ -51,10 +58,13 @@ services:
|
||||
- AUDITORIUM_HOST=http://localhost:9955
|
||||
|
||||
script:
|
||||
image: timbru31/node-chrome:slim
|
||||
build:
|
||||
context: '.'
|
||||
dockerfile: Dockerfile.node
|
||||
working_dir: /offen/script
|
||||
volumes:
|
||||
- .:/offen
|
||||
- scriptdeps:/offen/script/node_modules
|
||||
command: npm start -- --port 9966
|
||||
ports:
|
||||
- 9966:9966
|
||||
@ -62,12 +72,22 @@ services:
|
||||
- VAULT_HOST=http://localhost:9977
|
||||
|
||||
auditorium:
|
||||
image: timbru31/node-chrome:slim
|
||||
build:
|
||||
context: '.'
|
||||
dockerfile: Dockerfile.node
|
||||
working_dir: /offen/auditorium
|
||||
volumes:
|
||||
- .:/offen
|
||||
- auditoriumdeps_2:/offen/auditorium/node_modules
|
||||
command: npm start -- --port 9955
|
||||
ports:
|
||||
- 9955:9955
|
||||
environment:
|
||||
- VAULT_HOST=http://localhost:9977
|
||||
|
||||
volumes:
|
||||
kmsdeps:
|
||||
serverdeps:
|
||||
scriptdeps:
|
||||
auditoriumdeps_2:
|
||||
vaultdeps:
|
||||
|
Loading…
Reference in New Issue
Block a user