Skip to content

Commit

Permalink
added some deployment changes (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
amthorn authored Oct 4, 2021
1 parent 5c8308f commit 1163dd8
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 12 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ jobs:
with:
path: "**/node_modules"
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
- run: echo `openssl rand -hex 64` >> mongoPassword
- run: echo "DOESNTMATTER" >> token
- run: sudo docker run -v $(pwd)/mongoPassword:/run/secrets/mongoPassword -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_DATABASE=qutex -e MONGO_INITDB_ROOT_PASSWORD_FILE=/run/secrets/mongoPassword --name mongo -d -p 27017:27017 mongo:4.4.5
- run: |
mkdir -p secrets/local/
echo `openssl rand -hex 64` >> secrets/local/mongoPassword
echo "DOESNTMATTER" >> secrets/local/token
sudo docker run -v $(pwd)/secrets/local/mongoPassword:/run/secrets/mongoPassword -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_DATABASE=qutex -e MONGO_INITDB_ROOT_PASSWORD_FILE=/run/secrets/mongoPassword --name mongo -d -p 27017:27017 mongo:4.4.5
- env:
QUTEX_TESTING: true
run: yarn --cwd services/bot test --verbose
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ secrets.env
result.json
coverage/
.DS_Store
token
mongoPassword
site/
secrets

# Jekyll
docs/_site
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ up:

.PHONY: deploy $(VERSION)
deploy:
${MAKE} build
./bin/deploy_stack.sh $(VERSION)

.PHONY: logs
Expand Down
7 changes: 6 additions & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ services:
context: ./services/bot
mongo:
ports:
- 27017:27017
- 27017:27017
secrets:
token:
file: secrets/local/token
mongoPassword:
file: secrets/local/mongoPassword
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ services:
- mongoPassword
secrets:
token:
file: token
file: secrets/prod/token
mongoPassword:
file: mongoPassword
file: secrets/prod/mongoPassword
volumes:
mongo_volume:
2 changes: 1 addition & 1 deletion services/bot/migrate-mongo-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const GET = (secret) => {
if (['production', 'development'].includes(process.env.NODE_ENV || '')) {
return FS.readFileSync(`/run/secrets/${secret}`, 'utf8').trim();
} else {
return FS.readFileSync(`../../${secret}`, 'utf8').trim();
return FS.readFileSync(`../../secrets/local/${secret}`, 'utf8').trim();
}
};

Expand Down
2 changes: 1 addition & 1 deletion services/bot/src/secrets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export const GET = (secret: string): string => {
if (['production', 'development'].includes(process.env.NODE_ENV || '')) {
return fs.readFileSync(`/run/secrets/${secret}`, 'utf8').trim();
} else {
return fs.readFileSync(`../../${secret}`, 'utf8').trim();
return fs.readFileSync(`../../secrets/local/${secret}`, 'utf8').trim();
}
};
2 changes: 1 addition & 1 deletion services/bot/tests/production.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import mock from 'mock-fs';
mock({
'/run/secrets/': {
'token': 'some token',
'mongoPassword': mock.load('../../mongoPassword')
'mongoPassword': mock.load('../../secrets/local/mongoPassword')
},
'src': mock.load('src'),
'tests': mock.load('tests'),
Expand Down

0 comments on commit 1163dd8

Please sign in to comment.