Skip to content

Commit

Permalink
Add docker login when env vars are present
Browse files Browse the repository at this point in the history
  • Loading branch information
pziemkowski committed Sep 8, 2023
1 parent f27d38b commit 4055844
Show file tree
Hide file tree
Showing 29 changed files with 68 additions and 33 deletions.
6 changes: 3 additions & 3 deletions packages/infra/infra-shared/src/stacks/ci/ciBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class BackendCiConfig extends ServiceCiConfig {
commands: preBuildCommands,
},
build: {
commands: ['saas backend build'],
commands: ['pnpm saas backend build'],
},
},
}),
Expand Down Expand Up @@ -172,7 +172,7 @@ export class BackendCiConfig extends ServiceCiConfig {
PnpmWorkspaceFilters.BACKEND
),
},
build: { commands: ['saas backend deploy api'] },
build: { commands: ['pnpm saas backend deploy api'] },
},
cache: {
paths: [...this.defaultCachePaths],
Expand Down Expand Up @@ -235,7 +235,7 @@ export class BackendCiConfig extends ServiceCiConfig {
PnpmWorkspaceFilters.BACKEND
),
},
build: { commands: ['saas backend deploy migrations'] },
build: { commands: ['pnpm saas backend deploy migrations'] },
},
cache: {
paths: [...this.defaultCachePaths],
Expand Down
2 changes: 1 addition & 1 deletion packages/infra/infra-shared/src/stacks/ci/ciComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class ComponentsCiConfig extends ServiceCiConfig {
PnpmWorkspaceFilters.INFRA_SHARED
),
},
build: { commands: ['saas infra deploy components'] },
build: { commands: ['pnpm saas infra deploy components'] },
},
cache: {
paths: [...this.defaultCachePaths],
Expand Down
4 changes: 2 additions & 2 deletions packages/infra/infra-shared/src/stacks/ci/ciDocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class DocsCiConfig extends ServiceCiConfig {
pre_build: {
commands: preBuildCommands,
},
build: { commands: ['saas docs build'] },
build: { commands: ['pnpm saas docs build'] },
},
cache: {
paths: this.defaultCachePaths,
Expand Down Expand Up @@ -154,7 +154,7 @@ export class DocsCiConfig extends ServiceCiConfig {
pre_build: {
commands: this.getWorkspaceSetupCommands(PnpmWorkspaceFilters.DOCS),
},
build: { commands: ['saas docs deploy'] },
build: { commands: ['pnpm saas docs deploy'] },
},
cache: {
paths: [...this.defaultCachePaths],
Expand Down
8 changes: 4 additions & 4 deletions packages/infra/infra-shared/src/stacks/ci/ciServerless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ export class ServerlessCiConfig extends ServiceCiConfig {
},
build: {
commands: [
`saas workers lint`,
'saas emails build',
`saas workers test`,
`pnpm saas workers lint`,
'pnpm saas emails build',
`pnpm saas workers test`,
],
},
},
Expand Down Expand Up @@ -213,7 +213,7 @@ export class ServerlessCiConfig extends ServiceCiConfig {
pre_build: {
commands: preBuildCommands,
},
build: { commands: [`saas workers deploy`] },
build: { commands: [`pnpm saas workers deploy`] },
},
cache: {
paths: this.defaultCachePaths,
Expand Down
8 changes: 4 additions & 4 deletions packages/infra/infra-shared/src/stacks/ci/ciWebApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ export class WebappCiConfig extends ServiceCiConfig {
},
build: {
commands: [
'saas webapp lint',
'saas webapp test --watchAll=false',
'saas webapp build',
'pnpm saas webapp lint',
'pnpm saas webapp test --watchAll=false',
'pnpm saas webapp build',
],
},
},
Expand Down Expand Up @@ -149,7 +149,7 @@ export class WebappCiConfig extends ServiceCiConfig {
PnpmWorkspaceFilters.WEBAPP
),
},
build: { commands: ['saas webapp deploy'] },
build: { commands: ['pnpm saas webapp deploy'] },
},
cache: {
paths: [...this.defaultCachePaths],
Expand Down
3 changes: 2 additions & 1 deletion packages/internal/cli/src/commands/backend/black.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from '@oclif/core';

import { initConfig } from '../../config/init';
import { runCommand } from '../../lib/runCommand';
import { assertDockerIsRunning } from '../../lib/docker';
import {assertDockerIsRunning, dockerHubLogin} from '../../lib/docker';

export default class BackendBlack extends Command {
static description = 'Run black inside backend docker container';
Expand All @@ -12,6 +12,7 @@ export default class BackendBlack extends Command {
async run(): Promise<void> {
await initConfig(this, { requireLocalEnvStage: true });
await assertDockerIsRunning();
await dockerHubLogin();

await runCommand('docker', [
'compose',
Expand Down
2 changes: 2 additions & 0 deletions packages/internal/cli/src/commands/backend/build-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Command } from '@oclif/core';

import { initConfig } from '../../config/init';
import { runCommand } from '../../lib/runCommand';
import {dockerHubLogin} from "../../lib/docker";

export default class BackendBuild extends Command {
static description = 'Build backend docs and put results into docs package';
Expand All @@ -10,6 +11,7 @@ export default class BackendBuild extends Command {

async run(): Promise<void> {
await initConfig(this, {});
await dockerHubLogin();

await runCommand('pnpm', ['nx', 'run', 'backend:build-docs']);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/internal/cli/src/commands/backend/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { color } from '@oclif/color';

import { initConfig } from '../../config/init';
import { runCommand } from '../../lib/runCommand';
import {dockerHubLogin} from "../../lib/docker";

export default class BackendBuild extends Command {
static description = 'Build backend docker image and upload it to AWS ECR';
Expand All @@ -14,6 +15,7 @@ export default class BackendBuild extends Command {
this,
{ requireAws: true }
);
await dockerHubLogin();

this.log(`Building backend:
envStage: ${color.green(envStage)}
Expand Down
3 changes: 2 additions & 1 deletion packages/internal/cli/src/commands/backend/makemigrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from '@oclif/core';

import { initConfig } from '../../config/init';
import { runCommand } from '../../lib/runCommand';
import { assertDockerIsRunning } from '../../lib/docker';
import {assertDockerIsRunning, dockerHubLogin} from '../../lib/docker';

export default class BackendMakemigrations extends Command {
static description =
Expand All @@ -14,6 +14,7 @@ export default class BackendMakemigrations extends Command {
async run(): Promise<void> {
await initConfig(this, { requireLocalEnvStage: true });
await assertDockerIsRunning();
await dockerHubLogin();

await runCommand('docker', [
'compose',
Expand Down
3 changes: 2 additions & 1 deletion packages/internal/cli/src/commands/backend/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from '@oclif/core';

import { initConfig } from '../../config/init';
import { runCommand } from '../../lib/runCommand';
import { assertDockerIsRunning } from '../../lib/docker';
import {assertDockerIsRunning, dockerHubLogin} from '../../lib/docker';

export default class BackendMigrate extends Command {
static description =
Expand All @@ -14,6 +14,7 @@ export default class BackendMigrate extends Command {
async run(): Promise<void> {
await initConfig(this, { requireLocalEnvStage: true });
await assertDockerIsRunning();
await dockerHubLogin();

await runCommand('docker', [
'compose',
Expand Down
3 changes: 2 additions & 1 deletion packages/internal/cli/src/commands/backend/ruff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from '@oclif/core';

import { initConfig } from '../../config/init';
import { runCommand } from '../../lib/runCommand';
import { assertDockerIsRunning } from '../../lib/docker';
import {assertDockerIsRunning, dockerHubLogin} from '../../lib/docker';

export default class BackendRuff extends Command {
static description = 'Run ruff inside backend docker container';
Expand All @@ -12,6 +12,7 @@ export default class BackendRuff extends Command {
async run(): Promise<void> {
await initConfig(this, { requireLocalEnvStage: true });
await assertDockerIsRunning();
await dockerHubLogin();

await runCommand('docker', [
'compose',
Expand Down
3 changes: 2 additions & 1 deletion packages/internal/cli/src/commands/backend/secrets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from '@oclif/core';
import { color } from '@oclif/color';

import { initConfig } from '../../config/init';
import { assertDockerIsRunning } from '../../lib/docker';
import {assertDockerIsRunning, dockerHubLogin} from '../../lib/docker';
import { runSecretsEditor } from '../../lib/secretsEditor';

export default class BackendSecrets extends Command {
Expand All @@ -17,6 +17,7 @@ export default class BackendSecrets extends Command {
requireAws: true,
});
await assertDockerIsRunning();
await dockerHubLogin();

this.log(`Settings secrets in AWS SSM Parameter store for:
service: ${color.green('backend')}
Expand Down
3 changes: 2 additions & 1 deletion packages/internal/cli/src/commands/backend/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from '@oclif/core';

import { initConfig } from '../../config/init';
import { runCommand } from '../../lib/runCommand';
import { assertDockerIsRunning } from '../../lib/docker';
import {assertDockerIsRunning, dockerHubLogin} from '../../lib/docker';

export default class BackendShell extends Command {
static description =
Expand All @@ -13,6 +13,7 @@ export default class BackendShell extends Command {
async run(): Promise<void> {
await initConfig(this, { requireLocalEnvStage: true });
await assertDockerIsRunning();
await dockerHubLogin();

await runCommand('docker', [
'compose',
Expand Down
3 changes: 2 additions & 1 deletion packages/internal/cli/src/commands/backend/stripe/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from '@oclif/core';

import { initConfig } from '../../../config/init';
import { runCommand } from '../../../lib/runCommand';
import { assertDockerIsRunning } from '../../../lib/docker';
import {assertDockerIsRunning, dockerHubLogin} from '../../../lib/docker';

export default class BackendStripeSync extends Command {
static description =
Expand All @@ -14,6 +14,7 @@ export default class BackendStripeSync extends Command {
async run(): Promise<void> {
await initConfig(this, { requireLocalEnvStage: true });
await assertDockerIsRunning();
await dockerHubLogin();

await runCommand('docker', [
'compose',
Expand Down
3 changes: 2 additions & 1 deletion packages/internal/cli/src/commands/backend/up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from '@oclif/core';

import { initConfig } from '../../config/init';
import { runCommand } from '../../lib/runCommand';
import { assertDockerIsRunning } from '../../lib/docker';
import {assertDockerIsRunning, dockerHubLogin} from '../../lib/docker';

export default class BackendUp extends Command {
static description = 'Starts all backend services';
Expand All @@ -12,6 +12,7 @@ export default class BackendUp extends Command {
async run(): Promise<void> {
await initConfig(this, { requireLocalEnvStage: true });
await assertDockerIsRunning();
await dockerHubLogin();

await runCommand('pnpm', ['nx', 'run', 'core:docker-compose:up']);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/internal/cli/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Command, Flags } from '@oclif/core';

import { initConfig } from '../config/init';
import { runCommand } from '../lib/runCommand';
import { dockerHubLogin } from '../lib/docker';

export default class Build extends Command {
static description = 'Build all deployable artifacts';
Expand All @@ -10,6 +11,7 @@ export default class Build extends Command {

async run(): Promise<void> {
await initConfig(this, { requireAws: true });
await dockerHubLogin();

await runCommand('pnpm', ['nx', 'run', 'backend:build']);
await runCommand('pnpm', ['nx', 'run', 'webapp:build']);
Expand Down
3 changes: 2 additions & 1 deletion packages/internal/cli/src/commands/db/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from '@oclif/core';

import { initConfig } from '../../config/init';
import { runCommand } from '../../lib/runCommand';
import { assertDockerIsRunning } from '../../lib/docker';
import {assertDockerIsRunning, dockerHubLogin} from '../../lib/docker';

export default class DbShell extends Command {
static description =
Expand All @@ -20,6 +20,7 @@ export default class DbShell extends Command {
});

await assertDockerIsRunning();
await dockerHubLogin();

await runCommand('docker', ['compose', 'exec', 'db', 'psql'], {
env: {
Expand Down
2 changes: 1 addition & 1 deletion packages/internal/cli/src/commands/down.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from '@oclif/core';

import { initConfig } from '../config/init';
import { runCommand } from '../lib/runCommand';
import { assertDockerIsRunning } from '../lib/docker';
import {assertDockerIsRunning, dockerHubLogin} from '../lib/docker';

export default class Down extends Command {
static description = 'Starts both backend and frontend';
Expand Down
3 changes: 2 additions & 1 deletion packages/internal/cli/src/commands/up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from '@oclif/core';

import { initConfig } from '../config/init';
import { runCommand } from '../lib/runCommand';
import { assertDockerIsRunning } from '../lib/docker';
import {assertDockerIsRunning, dockerHubLogin} from '../lib/docker';

export default class Up extends Command {
static description = 'Starts both backend and frontend';
Expand All @@ -12,6 +12,7 @@ export default class Up extends Command {
async run(): Promise<void> {
await initConfig(this, { requireLocalEnvStage: true });
await assertDockerIsRunning();
await dockerHubLogin();

await runCommand('pnpm', ['nx', 'run', 'core:docker-compose:up']);
await runCommand('pnpm', ['nx', 'run', 'webapp:start']);
Expand Down
3 changes: 2 additions & 1 deletion packages/internal/cli/src/commands/webapp/secrets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from '@oclif/core';
import { color } from '@oclif/color';

import { initConfig } from '../../config/init';
import { assertDockerIsRunning } from '../../lib/docker';
import {assertDockerIsRunning, dockerHubLogin} from '../../lib/docker';
import { runSecretsEditor } from '../../lib/secretsEditor';

export default class WebappSecrets extends Command {
Expand All @@ -17,6 +17,7 @@ export default class WebappSecrets extends Command {
requireAws: true,
});
await assertDockerIsRunning();
await dockerHubLogin();

this.log(`Settings secrets in AWS SSM Parameter store for:
service: ${color.green('webapp')}
Expand Down
3 changes: 2 additions & 1 deletion packages/internal/cli/src/commands/workers/black.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command } from '@oclif/core';

import { initConfig } from '../../config/init';
import { runCommand } from '../../lib/runCommand';
import { assertDockerIsRunning } from '../../lib/docker';
import {assertDockerIsRunning, dockerHubLogin} from '../../lib/docker';

export default class WorkersBlack extends Command {
static description = 'Runs black inside workers docker container';
Expand All @@ -12,6 +12,7 @@ export default class WorkersBlack extends Command {
async run(): Promise<void> {
await initConfig(this, {});
await assertDockerIsRunning();
await dockerHubLogin();

await runCommand('docker', [
'compose',
Expand Down
2 changes: 2 additions & 0 deletions packages/internal/cli/src/commands/workers/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Command, Flags } from '@oclif/core';
import { initConfig } from '../../config/init';
import { runCommand } from '../../lib/runCommand';
import { color } from '@oclif/color';
import {dockerHubLogin} from "../../lib/docker";

export default class WorkersBuild extends Command {
static description = 'Build workers artifact ready to be deployed to AWS';
Expand All @@ -14,6 +15,7 @@ export default class WorkersBuild extends Command {
this,
{ requireAws: true }
);
await dockerHubLogin();

this.log(`Deploying backend:
envStage: ${color.green(envStage)}
Expand Down
4 changes: 3 additions & 1 deletion packages/internal/cli/src/commands/workers/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Command, Flags } from '@oclif/core';
import { color } from '@oclif/color';

import { initConfig } from '../../config/init';
import { runCommand } from '../../lib/runCommand';
import { color } from '@oclif/color';
import { dockerHubLogin } from '../../lib/docker';

export default class WorkersDeploy extends Command {
static description = 'Deploys workers to AWS using previously built artifact';
Expand All @@ -24,6 +25,7 @@ export default class WorkersDeploy extends Command {
this,
{ requireAws: true }
);
await dockerHubLogin();

this.log(`Deploying backend:
envStage: ${color.green(envStage)}
Expand Down
Loading

0 comments on commit 4055844

Please sign in to comment.