Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(env): pin Postgres #1915

Merged
merged 3 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions dev/docker-compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.9'
services:
nango-db:
image: postgres
image: postgres:15.5-alpine
container_name: nango-db
environment:
POSTGRES_PASSWORD: nango
Expand Down Expand Up @@ -31,10 +31,10 @@ services:
- nango

nango-redis:
image: "redis:latest"
image: 'redis:latest'
container_name: nango-redis
ports:
- "6379:6379"
- '6379:6379'
networks:
- nango

Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.9'
services:
nango-db:
image: postgres
image: postgres:15.5-alpine
container_name: nango-db
environment:
POSTGRES_PASSWORD: nango
Expand Down Expand Up @@ -45,10 +45,10 @@ services:
- nango

nango-redis:
image: "redis:latest"
image: 'redis:latest'
container_name: nango-redis
ports:
- "6379:6379"
- '6379:6379'
networks:
- nango

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.9'
services:
nango-db:
image: postgres
image: postgres:15.5-alpine
container_name: nango-db
environment:
POSTGRES_PASSWORD: nango
Expand Down
50 changes: 32 additions & 18 deletions tests/setup.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
import { GenericContainer, StartedTestContainer, TestContainer, Wait } from 'testcontainers';
import type { StartedTestContainer } from 'testcontainers';
import { Wait, PostgreSqlContainer } from 'testcontainers';

let startedContainer: StartedTestContainer;
const containers: StartedTestContainer[] = [];

export const setup = async () => {
const container: TestContainer = new GenericContainer('postgres');
startedContainer = await container
.withEnvironment({ POSTGRES_USER: 'postgres' })
.withEnvironment({ POSTGRES_PASSWORD: 'nango_test' })
.withEnvironment({ POSTGRES_DB: 'postgres' })
async function setupPostgres() {
const dbName = 'postgres';
const user = 'postgres';
const password = 'nango_test';
const container = new PostgreSqlContainer('postgres:15.5-alpine');
const pg = await container
.withDatabase(dbName)
.withUsername(user)
.withPassword(password)
.withExposedPorts(5432)
.withName('pg-test')
.withWaitStrategy(Wait.forLogMessage('database system is ready to accept connections'))
.start();

const port = startedContainer.getMappedPort(5432);
containers.push(pg);
const port = pg.getMappedPort(5432);

const testCred = 'nango_test';

process.env['NANGO_DB_PASSWORD'] = testCred;
process.env['NANGO_DB_PASSWORD'] = password;
process.env['NANGO_DB_HOST'] = 'localhost';
process.env['NANGO_DB_USER'] = 'postgres';
process.env['NANGO_DB_USER'] = user;
process.env['NANGO_DB_PORT'] = port.toString();
process.env['NANGO_DB_NAME'] = 'postgres';
process.env['NANGO_DB_NAME'] = dbName;
process.env['NANGO_DB_MIGRATION_FOLDER'] = './packages/shared/lib/db/migrations';
process.env['TELEMETRY'] = 'false';
};
}

export async function setup() {
await Promise.all([setupPostgres()]);
}
bodinsamuel marked this conversation as resolved.
Show resolved Hide resolved

export const teardown = async () => {
if (startedContainer) {
startedContainer.stop();
}
await Promise.all(
containers.map(async (container) => {
try {
await container.stop();
} catch (err) {
console.error(err);
}
})
);
};