@abgov/nx-oc 12.12.0 → 12.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/generators/deployment/deployment.spec.ts +1 -2
- package/src/generators/deployment/node-files/__projectName__.yml__tmpl__ +1 -1
- package/src/generators/pipeline/actions/workflows/pipeline.yml__tmpl__ +1 -0
- package/src/generators/sandbox/database-files/sandbox-postgres.yml__tmpl__ +3 -1
- package/src/generators/sandbox/sandbox.js +9 -0
- package/src/generators/sandbox/sandbox.js.map +1 -1
- package/src/generators/sandbox/sandbox.spec.ts +6 -0
- package/src/generators/deployment/dotnet-files/Dockerfile.template +0 -10
- package/src/generators/deployment/frontend-files/Dockerfile.template +0 -8
- package/src/generators/deployment/node-files/Dockerfile.template +0 -8
package/package.json
CHANGED
|
@@ -218,8 +218,7 @@ describe('Deployment Generator', () => {
|
|
|
218
218
|
const manifest = host.read('.openshift/test/test.yml').toString();
|
|
219
219
|
expect(manifest).toContain('DATABASE_URL');
|
|
220
220
|
expect(manifest).toContain('initContainers');
|
|
221
|
-
expect(manifest).toContain('
|
|
222
|
-
expect(manifest).toContain('migrate');
|
|
221
|
+
expect(manifest).toContain('migrate.js');
|
|
223
222
|
});
|
|
224
223
|
|
|
225
224
|
it('includes MONGODB_URI secretKeyRef without init container for mongo node deployment', async () => {
|
|
@@ -91,7 +91,7 @@ objects:
|
|
|
91
91
|
<% } else { %>
|
|
92
92
|
image: image-registry.openshift-image-registry.svc:5000/${INFRA_PROJECT}/${APP_NAME}:${DEPLOY_TAG}
|
|
93
93
|
<% } %>
|
|
94
|
-
command: ["
|
|
94
|
+
command: ["node", "migrate.js"]
|
|
95
95
|
envFrom:
|
|
96
96
|
- configMapRef:
|
|
97
97
|
name: ${APP_NAME}
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
# deleted on re-apply, so data persists across deployments.
|
|
4
4
|
#
|
|
5
5
|
# Multiple apps in the same namespace share this instance. Each app uses its
|
|
6
|
-
# own database (<appName>_sandbox)
|
|
6
|
+
# own database (<appName>_sandbox): the `nx run <app>:sandbox` target creates it
|
|
7
|
+
# (idempotently) after Postgres is ready, and the app's migrate init container
|
|
8
|
+
# applies the schema on deploy.
|
|
7
9
|
#
|
|
8
10
|
# Credentials are stored in the sandbox-postgres-creds Secret, created once
|
|
9
11
|
# per namespace by `nx run <app>:sandbox` on first use. Subsequent apps read
|
|
@@ -50,6 +50,15 @@ function addSandboxTarget(host, options) {
|
|
|
50
50
|
`--from-literal=POSTGRESQL_ADMIN_PASSWORD=$(openssl rand -base64 24 | tr -d '/+=') ` +
|
|
51
51
|
`-n ${sandboxProject}`);
|
|
52
52
|
commands.push(`oc apply -f .openshift/sandbox/sandbox-postgres.yml -n ${sandboxProject}`);
|
|
53
|
+
// The shared Postgres instance only creates the admin database; each app
|
|
54
|
+
// needs its own <app>_sandbox database created before its migrate init
|
|
55
|
+
// container runs (neither the image nor the ORM creates it). Wait for
|
|
56
|
+
// Postgres to be ready, then create the database idempotently.
|
|
57
|
+
const dbName = `${projectName}_sandbox`;
|
|
58
|
+
commands.push(`oc rollout status deployment/sandbox-postgres -n ${sandboxProject} --timeout=180s && ` +
|
|
59
|
+
`oc exec -n ${sandboxProject} deployment/sandbox-postgres -- ` +
|
|
60
|
+
`bash -lc "psql -U postgres -tc \\"SELECT 1 FROM pg_database WHERE datname='${dbName}'\\" ` +
|
|
61
|
+
`| grep -q 1 || createdb -U postgres ${dbName}"`);
|
|
53
62
|
}
|
|
54
63
|
else if (database === 'mongo') {
|
|
55
64
|
commands.push(`oc get secret sandbox-mongodb-creds -n ${sandboxProject} 2>/dev/null || ` +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../../../../../../packages/nx-oc/src/generators/sandbox/sandbox.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"sandbox.js","sourceRoot":"","sources":["../../../../../../packages/nx-oc/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CAAC;QACvC,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;QAC1C,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;QAC1C,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA"}
|
|
@@ -143,6 +143,12 @@ describe('Sandbox Generator', () => {
|
|
|
143
143
|
const cmds: string[] = config.targets['sandbox'].options.commands;
|
|
144
144
|
expect(cmds.some((c) => c.includes('sandbox-postgres-creds'))).toBeTruthy();
|
|
145
145
|
expect(cmds.some((c) => c.includes('sandbox-postgres.yml'))).toBeTruthy();
|
|
146
|
+
// The per-app database is created idempotently before the app deploys.
|
|
147
|
+
expect(cmds.some((c) => c.includes('createdb -U postgres test_sandbox'))).toBeTruthy();
|
|
148
|
+
const createDbIdx = cmds.findIndex((c) => c.includes('createdb'));
|
|
149
|
+
const rolloutIdx = cmds.findIndex((c) => c.includes('rollout status deployment/test'));
|
|
150
|
+
expect(createDbIdx).toBeGreaterThanOrEqual(0);
|
|
151
|
+
expect(createDbIdx).toBeLessThan(rolloutIdx);
|
|
146
152
|
});
|
|
147
153
|
|
|
148
154
|
it('generates shared mongodb manifest with secret-backed MONGODB_URI', async () => {
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# This is a minimal Dockerfile for app deployment.
|
|
2
|
-
FROM registry.access.redhat.com/ubi8/dotnet-60-runtime
|
|
3
|
-
|
|
4
|
-
ARG ASSEMBLY
|
|
5
|
-
|
|
6
|
-
# Build output path mirrors the workspace layout (from the project's build target).
|
|
7
|
-
COPY ./<%= buildOutputPath %>/net6.0 .
|
|
8
|
-
|
|
9
|
-
ENV ASSEMBLY ${ASSEMBLY}
|
|
10
|
-
CMD dotnet ${ASSEMBLY}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# This is a minimal Dockerfile for app deployment.
|
|
2
|
-
FROM registry.access.redhat.com/ubi8/nginx-118
|
|
3
|
-
|
|
4
|
-
# Build output path mirrors the workspace layout (from the project's build target).
|
|
5
|
-
COPY ./<%= buildOutputPath %>/nginx.conf "${NGINX_CONF_PATH}"
|
|
6
|
-
COPY ./<%= buildOutputPath %> .
|
|
7
|
-
|
|
8
|
-
CMD nginx -g "daemon off;"
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# This is a minimal Dockerfile for app deployment.
|
|
2
|
-
FROM registry.access.redhat.com/ubi8/nodejs-18
|
|
3
|
-
|
|
4
|
-
# Build output path mirrors the workspace layout (from the project's build target).
|
|
5
|
-
COPY ./<%= buildOutputPath %> .
|
|
6
|
-
COPY ./node_modules ./node_modules
|
|
7
|
-
|
|
8
|
-
CMD node main.js
|