Skip to content

Commit

Permalink
fix: sensible defaults in docker-compose files
Browse files Browse the repository at this point in the history
  • Loading branch information
Si committed Oct 12, 2022
1 parent 71e5a87 commit f631f75
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 53 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
username: ${{ secrets.SERVER_USER}}
key: ${{ secrets.SSH_KEY }}
port: 22
script_stop: true
script: |
cd api
git pull
Expand Down
31 changes: 24 additions & 7 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Unit tests

on:
push:
branches:
Expand All @@ -17,20 +19,35 @@ jobs:
- name: Checkout
uses: actions/checkout@v1

- name: Start containers
run: docker-compose -f "docker-compose.test.yml" up -d --build

- name: Install node
uses: actions/setup-node@v1
with:
node-version: 14.x

- name: Install dependencies
run: yarn install
- name: Copy env file
run: |
cp .env.example .env
cp jwk-keys.json.example jwk-keys.json
cp cookies-keys.json.example cookies-keys.json
- name: Install
run: yarn install --force

- name: Start containers
run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up -d --build

- name: Migrations
run: docker exec resonate-api npx sequelize db:migrate --config src/config/databases.js --migrations-path src/db/migrations

- name: Seed data
run: docker exec resonate-api npx sequelize db:seed:all --config src/config/databases.js --seeders-path src/db/seeders/test

- name: Sleep to give things time to start
run: sleep 30s

- name: Run tests
run: yarn test:all --exit
run: docker exec resonate-api yarn mocha test --exit

- name: Stop containers
if: always()
run: docker-compose -f "docker-compose.yml" down
run: docker-compose down
2 changes: 1 addition & 1 deletion .mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

module.exports = {
"reporter": "spec",
"watch": true,
"watch": process.env.CI ? false : true,
"watch-files": ['test/**/*.js', 'src/**/*.js'],
"watch-ignore": ['node_modules'],
// "file": 'test/common.js',
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ services:
build: .
command: /bin/sh -c "yarn && yarn migrate:test && yarn start:dev"
container_name: resonate-api
env_file: .env
environment:
- NODE_ENV=test
- CI=${CI:-false}
depends_on:
- redis
- pgsql
Expand All @@ -35,6 +37,6 @@ services:
aliases:
- pgsql
ports:
- '${POSTGRES_TEST_LOCAL_MACHINE_PORT}:5432'
- '${POSTGRES_TEST_LOCAL_MACHINE_PORT:-5432}:5432'

version: "3.7"
12 changes: 6 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
expose:
- 6379
ports:
- "${REDIS_PORT}:6379"
- "${REDIS_PORT:-6379}:6379"

api:
networks:
Expand All @@ -35,9 +35,9 @@ services:
volumes:
- ~/.ssh:/root/.ssh
- ./:/var/www/api
- ${MEDIA_LOCATION}incoming:/data/media/incoming
- ${MEDIA_LOCATION}audio:/data/media/audio
- ${MEDIA_LOCATION}images:/data/media/images
- ${MEDIA_LOCATION:-./data/media/}incoming:/data/media/incoming
- ${MEDIA_LOCATION:-./data/media/}audio:/data/media/audio
- ${MEDIA_LOCATION:-./data/media/}images:/data/media/images

pgsql:
image: postgres:14-alpine
Expand All @@ -52,7 +52,7 @@ services:
aliases:
- pgsql
ports:
- '${POSTGRES_LOCAL_MACHINE_PORT}:5432'
- '${POSTGRES_LOCAL_MACHINE_PORT:-5432}:5432'

nginx:
restart: always
Expand All @@ -68,7 +68,7 @@ services:
target: ${IMAGE:-dev-image}

ports:
- "${NGINX_PORT}:80"
- "${NGINX_PORT:-80}:80"
- 443:443

networks:
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@
"sequelize-cli": "^6.2.0",
"server-destroy": "^1.0.1",
"ssh2": "^1.11.0",
"ssh2-promise": "^1.0.3",
"standard": "^16.0.4",
"supertest": "^4.0.2",
"tunnel-ssh": "^4.1.6"
Expand Down
2 changes: 1 addition & 1 deletion test/testConfig.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

const baseURL = 'http://localhost:4000/api/v3'
const baseURL = `${process.env.APP_HOST}/api/v3`
const request = require('supertest')(baseURL)

const expect = require('chai').expect
Expand Down
38 changes: 2 additions & 36 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1005,13 +1005,6 @@
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.3.0.tgz#8368869dcb735be2e7f5cb7647de78e167a251fb"
integrity sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==

"@heroku/socksv5@^0.0.9":
version "0.0.9"
resolved "https://registry.yarnpkg.com/@heroku/socksv5/-/socksv5-0.0.9.tgz#7a3905921136b2666979a0f86bb4f062f657f793"
integrity sha512-bV8v7R/c0gNve8i7yPmZbcCTJUqRbCnMSvcegcMaz+ly+FoZf9i4+3MTjKsX+OZn9w0w1I6VJYQBcdM+yMWPQQ==
dependencies:
ip-address "^5.8.8"

"@ioredis/commands@^1.1.1":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@ioredis/commands/-/commands-1.2.0.tgz#6d61b3097470af1fdbbe622795b8921d42018e11"
Expand Down Expand Up @@ -4144,15 +4137,6 @@ ioredis@^5.2.2:
redis-parser "^3.0.0"
standard-as-callback "^2.1.0"

ip-address@^5.8.8:
version "5.9.4"
resolved "https://registry.yarnpkg.com/ip-address/-/ip-address-5.9.4.tgz#4660ac261ad61bd397a860a007f7e98e4eaee386"
integrity sha512-dHkI3/YNJq4b/qQaz+c8LuarD3pY24JqZWfjB8aZx1gtpc2MDILu9L9jpZe1sHpzo/yWFweQVn+U//FhazUxmw==
dependencies:
jsbn "1.1.0"
lodash "^4.17.15"
sprintf-js "1.1.2"

is-arrayish@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d"
Expand Down Expand Up @@ -4451,11 +4435,6 @@ js-yaml@^3.10.0, js-yaml@^3.13.1:
argparse "^1.0.7"
esprima "^4.0.0"

[email protected]:
version "1.1.0"
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-1.1.0.tgz#b01307cb29b618a1ed26ec79e911f803c4da0040"
integrity sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==

jsbn@~0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
Expand Down Expand Up @@ -4979,7 +4958,7 @@ lodash.truncate@^4.4.2:
resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193"
integrity sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==

lodash@^4.17.15, lodash@^4.17.20, lodash@^4.17.21:
lodash@^4.17.20, lodash@^4.17.21:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
Expand Down Expand Up @@ -7179,11 +7158,6 @@ split2@^4.1.0:
resolved "https://registry.yarnpkg.com/split2/-/split2-4.1.0.tgz#101907a24370f85bb782f08adaabe4e281ecf809"
integrity sha512-VBiJxFkxiXRlUIeyMQi8s4hgvKCSjtknJv/LVYbrgALPwf5zSKmEwV9Lst25AkvMDnvxODugjdl6KZgwKM1WYQ==

[email protected]:
version "1.1.2"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.2.tgz#da1765262bf8c0f571749f2ad6c26300207ae673"
integrity sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==

sprintf-js@~1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
Expand All @@ -7199,14 +7173,6 @@ sqlstring@^2.3.1, sqlstring@^2.3.2:
resolved "https://registry.yarnpkg.com/sqlstring/-/sqlstring-2.3.3.tgz#2ddc21f03bce2c387ed60680e739922c65751d0c"
integrity sha512-qC9iz2FlN7DQl3+wjwn3802RTyjCx7sDvfQEXchwa6CWOx07/WVfh91gBmQ9fahw8snwGEWU3xGzOt4tFyHLxg==

ssh2-promise@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/ssh2-promise/-/ssh2-promise-1.0.3.tgz#7c890e3f27536abf02b55337a307e49420004dda"
integrity sha512-842MuERRLuGdTneOZhc5HeogBtGFI/WeeJ9LH3Jp+eB57av8hHGDzxZqgWuQmuxVDniRf7B+agSfgc2wKfLY4w==
dependencies:
"@heroku/socksv5" "^0.0.9"
ssh2 "^1.10.0"

ssh2-streams@~0.1.18:
version "0.1.20"
resolved "https://registry.yarnpkg.com/ssh2-streams/-/ssh2-streams-0.1.20.tgz#51118d154555df5469ee1f67e0cf1e7e8a2c0e3a"
Expand Down Expand Up @@ -7234,7 +7200,7 @@ ssh2@^0.5.4:
dependencies:
ssh2-streams "~0.1.18"

ssh2@^1.10.0, ssh2@^1.11.0:
ssh2@^1.11.0:
version "1.11.0"
resolved "https://registry.yarnpkg.com/ssh2/-/ssh2-1.11.0.tgz#ce60186216971e12f6deb553dcf82322498fe2e4"
integrity sha512-nfg0wZWGSsfUe/IBJkXVll3PEZ//YH2guww+mP88gTpuSU4FtZN7zu9JoeTGOyCNx2dTDtT9fOpWwlzyj4uOOw==
Expand Down

0 comments on commit f631f75

Please sign in to comment.