-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #179 from celluloid-camp/create-knex-migration
Add knex migration
- Loading branch information
Showing
33 changed files
with
1,226 additions
and
2,175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
NODE_ENV=test | ||
|
||
# HTTP server port. Do not change unless you know what you're doing. | ||
CELLULOID_LISTEN_PORT=3001 | ||
# Postgres server IP address or hostname. | ||
CELLULOID_PG_HOST=postgres | ||
# Postgres port. | ||
CELLULOID_PG_PORT=5432 | ||
# Postgres database name. | ||
CELLULOID_PG_DATABASE=postgres | ||
# Postgres database user. | ||
CELLULOID_PG_USER=postgres | ||
# Postgres database password. | ||
CELLULOID_PG_PASSWORD=postgres | ||
# Postgres connection pool config. Change at your own risk. | ||
CELLULOID_PG_MAX_POOL_SIZE=20 | ||
CELLULOID_PG_IDLE_TIMEOUT=30000 | ||
# Cookie secret key. Generate something random and long. | ||
CELLULOID_COOKIE_SECRET=cisecret3 | ||
|
||
CELLULOID_REDIS_URL=redis://localhost | ||
|
||
# email params. Check with your SMTP provider | ||
CELLULOID_SMTP_HOST= | ||
CELLULOID_SMTP_USER= | ||
CELLULOID_SMTP_PASSWORD= | ||
CELLULOID_SMTP_TLS=false | ||
CELLULOID_SMTP_PORT=465 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Dockerfile CI | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [16.x] | ||
|
||
services: | ||
redis: | ||
image: redis | ||
ports: | ||
- "0.0.0.0:6379:6379" | ||
postgres: | ||
image: postgres:14 | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: postgres | ||
ports: | ||
- "0.0.0.0:5432:5432" | ||
# needed because the postgres container does not provide a healthcheck | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: setup database | ||
run: | | ||
cp .env.ci .env | ||
yarn --frozen-lockfile | ||
env: | ||
CI: true | ||
- name: "Run docker server build" | ||
run: | ||
docker build --tag celluloid-server . | ||
- name: "ifconfig -a" | ||
run: "ifconfig -a" | ||
- name: "Start docker server" | ||
run: | ||
docker run --rm -d --init -p 3001:3001 --env-file .env -e NODE_ENV=production -e CELLULOID_PG_HOST=172.17.0.1 -e CELLULOID_REDIS_URL=redis://172.17.0.1 | ||
--name celluloid-server celluloid-server | ||
- name: "Test docker" | ||
run: node .github/workflows/test-docker.js | ||
- name: "Tear down docker" | ||
run: docker kill celluloid-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const fetch = require("node-fetch"); | ||
const AbortController = require("abort-controller"); | ||
const { execSync } = require("child_process"); | ||
|
||
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); | ||
|
||
async function main() { | ||
let attempts = 0; | ||
let response; | ||
while (true) { | ||
try { | ||
const controller = new AbortController(); | ||
const timeout = setTimeout(() => { | ||
controller.abort(); | ||
}, 3000); | ||
try { | ||
response = await fetch("http://localhost:3001", { | ||
signal: controller.signal, | ||
}); | ||
} finally { | ||
clearTimeout(timeout); | ||
} | ||
if (!response.ok) { | ||
throw new Error("Try again"); | ||
} | ||
break; | ||
} catch (e) { | ||
attempts++; | ||
if (attempts <= 30) { | ||
console.log(`Server is not ready yet: ${e.message}`); | ||
execSync("docker logs celluloid-server", { stdio: "inherit" }); | ||
} else { | ||
console.log(`Server never came up, aborting :(`); | ||
process.exit(1); | ||
} | ||
await sleep(1000); | ||
} | ||
} | ||
const text = await response.text(); | ||
|
||
// Check for known text on homepage | ||
if (!text.includes("Institut Catholique de Paris")) { | ||
throw new Error("Failed to confirm server works."); | ||
} | ||
|
||
console.log("Docker tests passed."); | ||
} | ||
|
||
main().catch((e) => { | ||
console.error(e); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.