Skip to content

Commit

Permalink
Add support for using Docker Compose
Browse files Browse the repository at this point in the history
Also using Docker for development now makes use of the local Doppler config instead of requiring a service token.
  • Loading branch information
ryan-blunden committed Oct 15, 2020
1 parent d53a595 commit 79c6f9f
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 15 deletions.
25 changes: 22 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,42 @@ docker-run:
docker container run \
-it \
--rm \
--init \
-d \
--name $(CONTAINER_NAME) \
-e DOPPLER_TOKEN=${YODASPEAK_SERVICE_TOKEN} \
-p 3000:3000 $(IMAGE_NAME):latest
-p 3000:3000 \
-p 3443:3443 \
$(IMAGE_NAME):latest

docker-compose-up:
docker-compose up

docker-compose-dev:
DOPPLER_TOKEN="$(shell doppler configure get token --plain)" \
DOPPLER_PROJECT="$(shell doppler configure get project --plain)" \
DOPPLER_CONFIG="$(shell doppler configure get config --plain)" \
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up; docker-compose rm -fsv

# Required to install dev dependencies
docker-run-dev:
docker container run \
-it \
--init \
--name $(CONTAINER_NAME) \
--rm \
-e DOPPLER_TOKEN=${YODASPEAK_SERVICE_TOKEN} \
-e "DOPPLER_TOKEN=$(shell doppler configure get token --plain)" \
-e "DOPPLER_PROJECT=$(shell doppler configure get project --plain)" \
-e "DOPPLER_CONFIG=$(shell doppler configure get config --plain)" \
-v $(shell pwd):/usr/src/app:cached \
-u root \
-p 3443:3443 \
-p 3000:3000 \
$(IMAGE_NAME):latest \
/bin/sh -c '. ./bin/docker-dev-setup.sh && sh'
./bin/docker-dev-command.sh

docker-shell:
docker container exec -it $(CONTAINER_NAME) sh


###############
Expand Down
13 changes: 13 additions & 0 deletions bin/docker-dev-command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
set -e

echo "[info]: Configuring container for development"
echo "[info]: Doppler config: $DOPPLER_PROJECT => $DOPPLER_CONFIG"
echo "[info]: Installing development dependencies"
cp package.json -f ../
cd ../
npm install --only=dev && cd ./app
export PATH=$PATH:/usr/src/node_modules/.bin
echo "[info]: Development environment configured"
echo "[info]: Starting server"
nodemon npm start
10 changes: 0 additions & 10 deletions bin/docker-dev-setup.sh

This file was deleted.

12 changes: 12 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
web:
user: root # Required to install dev dependencies
stdin_open: true
tty: true
environment:
DOPPLER_TOKEN: $DOPPLER_TOKEN
DOPPLER_PROJECT: $DOPPLER_PROJECT
DOPPLER_CONFIG: $DOPPLER_CONFIG
volumes:
- .:/usr/src/app
command: ./bin/docker-dev-command.sh
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
web:
build: .
image: dopplerhq/yodaspeak
container_name: yodaspeak
init: true
environment:
DOPPLER_TOKEN: $YODASPEAK_SERVICE_TOKEN
ports:
- 3000:3000
- 3443:3443
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"type": "module",
"scripts": {
"start": "node ./src/server",
"local": "nodemon ./src/server",
"lint": "eslint --fix --quiet",
"format": "prettier --write --loglevel error .",
"build-static": "node ./src/build.js",
"doppler-cloud-install-standalone": "wget -q https://github.com/DopplerHQ/cli/releases/download/3.13.0/doppler_3.13.0_linux_amd64.tar.gz && tar -xf doppler_3.13.0_linux_amd64.tar.gz && rm doppler_3.13.0_linux_amd64.tar.gz && chmod +x ./doppler && ./doppler --version"
"build-static": "node ./src/build.js"
},
"nodemonConfig": {
"ext": "*.js,*.css,*.nunjucks",
Expand Down

0 comments on commit 79c6f9f

Please sign in to comment.