Skip to content

Commit

Permalink
add docker builds
Browse files Browse the repository at this point in the history
Signed-off-by: Mirko Mollik <[email protected]>
  • Loading branch information
Mirko Mollik committed May 8, 2024
1 parent c11b0d3 commit a07bda2
Show file tree
Hide file tree
Showing 44 changed files with 584 additions and 115 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
4 changes: 4 additions & 0 deletions apps/holder-app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM docker.io/nginx:stable-alpine
COPY dist/apps/holder-app/* /usr/share/nginx/html/
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
16 changes: 14 additions & 2 deletions apps/holder-app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
"maximumWarning": "2mb",
"maximumError": "2mb"
},
{
"type": "anyComponentStyle",
Expand Down Expand Up @@ -80,6 +80,18 @@
"options": {
"jestConfig": "apps/holder-app/jest.config.ts"
}
},
"container": {
"executor": "@nx-tools/nx-container:build",
"dependsOn": ["build"],
"options": {
"engine": "docker",
"metadata": {
"images": ["ghcr.io/cre8/wallet/holder-app"],
"load": true,
"tags": ["latest"]
}
}
}
}
}
23 changes: 23 additions & 0 deletions apps/holder-backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Install dependencies only when needed
FROM docker.io/node:lts-alpine as deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /usr/src/app
COPY dist/apps/holder-backend/package*.json ./
COPY dist/apps/holder-backend/pnpm-lock.yaml ./
RUN npm install -g [email protected]
RUN pnpm install --prod

# Production image, copy all the files and run nest
FROM docker.io/node:lts-alpine as runner
RUN apk add --no-cache dumb-init
ENV NODE_ENV production
ENV PORT 3000
WORKDIR /usr/src/app
COPY --from=deps /usr/src/app/node_modules ./node_modules
COPY --from=deps /usr/src/app/package.json ./package.json
COPY dist/apps/holder-backend .
RUN chown -R node:node .
USER node
EXPOSE 3000
CMD ["dumb-init", "node", "main.js"]
18 changes: 18 additions & 0 deletions apps/holder-backend/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@
"buildTarget": "holder-backend:build:production"
}
}
},
"container": {
"executor": "@nx-tools/nx-container:build",
"dependsOn": ["build"],
"options": {
"engine": "docker",
"metadata": {
"images": ["holder-backend"],
"load": true,
"tags": [
"type=schedule",
"type=ref,event=branch",
"type=ref,event=tag",
"type=ref,event=pr",
"type=sha,prefix=sha-"
]
}
}
}
}
}
4 changes: 0 additions & 4 deletions apps/holder-backend/src/app/db/db.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,21 @@ export const DB_VALIDATION_SCHEMA = {
DB_TYPE: Joi.string().default('postgres'),
DB_HOST: Joi.string().when('DB_TYPE', {
is: 'postgres',
// biome-ignore lint/suspicious/noThenProperty: <explanation>
then: Joi.required(),
otherwise: Joi.optional(),
}),
DB_PORT: Joi.number().when('DB_TYPE', {
is: 'postgres',
// biome-ignore lint/suspicious/noThenProperty: <explanation>
then: Joi.required(),
otherwise: Joi.optional(),
}),
DB_USERNAME: Joi.string().when('DB_TYPE', {
is: 'postgres',
// biome-ignore lint/suspicious/noThenProperty: <explanation>
then: Joi.required(),
otherwise: Joi.optional(),
}),
DB_PASSWORD: Joi.string().when('DB_TYPE', {
is: 'postgres',
// biome-ignore lint/suspicious/noThenProperty: <explanation>
then: Joi.required(),
otherwise: Joi.optional(),
}),
Expand Down
3 changes: 0 additions & 3 deletions apps/holder-backend/src/app/keys/keys.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@ export const KEY_VALIDATION_SCHEMA = {
KM_TYPE: Joi.string().valid('db', 'vault').default('db'),
VAULT_URL: Joi.string().when('KM_TYPE', {
is: 'vault',
// biome-ignore lint/suspicious/noThenProperty: <explanation>
then: Joi.required(),
otherwise: Joi.optional(),
}),
VAULT_TOKEN: Joi.string().when('KM_TYPE', {
is: 'vault',
// biome-ignore lint/suspicious/noThenProperty: <explanation>
then: Joi.required(),
otherwise: Joi.optional(),
}),
};
@Global()
@Module({})
// biome-ignore lint/complexity/noStaticOnlyClass: <explanation>
export class KeysModule {
static forRootSync(): DynamicModule {
return {
Expand Down
2 changes: 2 additions & 0 deletions apps/holder-backend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module.exports = {
assets: ['./src/assets'],
optimization: false,
outputHashing: 'none',
generatePackageJson: true,
transformers: [{ name: '@nestjs/swagger/plugin' }],
}),
],
};
2 changes: 0 additions & 2 deletions apps/holder-browser-extension/src/content-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ function scanForQRCode() {
const canvases = document.querySelectorAll('canvas');
toProcess = canvases.length + images.length;
chrome.runtime.sendMessage({ action: 'process', data: 'scanning' });
// biome-ignore lint/complexity/noForEach: <explanation>
images.forEach((image) => scanImage(image));
// biome-ignore lint/complexity/noForEach: <explanation>
canvases.forEach((canvas) => {
const imageData = canvas.toDataURL();
readImage(imageData, canvas);
Expand Down
4 changes: 3 additions & 1 deletion apps/issuer-backend/.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ KEYCLOAK_CLIENT_ID=issuer
DB_TYPE=sqlite
DB_NAME=tmp/db.sqlite

CREDENTIALS_FOLDER=config/issuer
CREDENTIALS_FOLDER=config/issuer-backend

# KM_TYPE=vault
# VAULT_URL=http://localhost:8200/v1/transit
# VAULT_TOKEN=root
# VAULT_KEY_ID=12345678

KM_FOLDER=tmp/issuer/
6 changes: 5 additions & 1 deletion apps/issuer-backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ KEYCLOAK_CLIENT_ID=issuer

# DB config
DB_TYPE=sqlite
DB_NAME=tmp/db.sqlite
DB_NAME=tmp/db.sqlite

CREDENTIALS_FOLDER=config/issuer-backend

KM_FOLDER=tmp/issuer/
23 changes: 23 additions & 0 deletions apps/issuer-backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Install dependencies only when needed
FROM docker.io/node:lts-alpine as deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /usr/src/app
COPY dist/apps/holder-backend/package*.json ./
COPY dist/apps/holder-backend/pnpm-lock.yaml ./
RUN npm install -g [email protected]
RUN pnpm install --prod

# Production image, copy all the files and run nest
FROM docker.io/node:lts-alpine as runner
RUN apk add --no-cache dumb-init
ENV NODE_ENV production
ENV PORT 3000
WORKDIR /usr/src/app
COPY --from=deps /usr/src/app/node_modules ./node_modules
COPY --from=deps /usr/src/app/package.json ./package.json
COPY dist/apps/holder-backend .
RUN chown -R node:node .
USER node
EXPOSE 3000
CMD ["dumb-init", "node", "main.js"]
12 changes: 12 additions & 0 deletions apps/issuer-backend/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
"buildTarget": "issuer-backend:build:production"
}
}
},
"container": {
"executor": "@nx-tools/nx-container:build",
"dependsOn": ["build"],
"options": {
"engine": "docker",
"metadata": {
"images": ["ghcr.io/cre8/wallet/issuer-backend"],
"load": true,
"tags": ["latest"]
}
}
}
}
}
4 changes: 0 additions & 4 deletions apps/issuer-backend/src/app/db/db.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,21 @@ export const DB_VALIDATION_SCHEMA = {
DB_TYPE: Joi.string().default('postgres'),
DB_HOST: Joi.string().when('DB_TYPE', {
is: 'postgres',
// biome-ignore lint/suspicious/noThenProperty: <explanation>
then: Joi.required(),
otherwise: Joi.optional(),
}),
DB_PORT: Joi.number().when('DB_TYPE', {
is: 'postgres',
// biome-ignore lint/suspicious/noThenProperty: <explanation>
then: Joi.required(),
otherwise: Joi.optional(),
}),
DB_USERNAME: Joi.string().when('DB_TYPE', {
is: 'postgres',
// biome-ignore lint/suspicious/noThenProperty: <explanation>
then: Joi.required(),
otherwise: Joi.optional(),
}),
DB_PASSWORD: Joi.string().when('DB_TYPE', {
is: 'postgres',
// biome-ignore lint/suspicious/noThenProperty: <explanation>
then: Joi.required(),
otherwise: Joi.optional(),
}),
Expand Down
1 change: 1 addition & 0 deletions apps/issuer-backend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
assets: ['./src/assets'],
optimization: false,
outputHashing: 'none',
transformers: [{ name: '@nestjs/swagger/plugin' }],
}),
],
};
4 changes: 4 additions & 0 deletions apps/issuer-frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM docker.io/nginx:stable-alpine
COPY dist/apps/issuer-frontend/* /usr/share/nginx/html/
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
12 changes: 12 additions & 0 deletions apps/issuer-frontend/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@
"options": {
"jestConfig": "apps/issuer-frontend/jest.config.ts"
}
},
"container": {
"executor": "@nx-tools/nx-container:build",
"dependsOn": ["build"],
"options": {
"engine": "docker",
"metadata": {
"images": ["ghcr.io/cre8/wallet/issuer-frontend"],
"load": true,
"tags": ["latest"]
}
}
}
}
}
2 changes: 2 additions & 0 deletions apps/verifier-backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ KEYCLOAK_REALM=wallet
KEYCLOAK_CLIENT_ID=issuer

CREDENTIALS_FOLDER=config/verifier

KM_FOLDER=tmp/verifier/
23 changes: 23 additions & 0 deletions apps/verifier-backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Install dependencies only when needed
FROM docker.io/node:lts-alpine as deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /usr/src/app
COPY dist/apps/holder-backend/package*.json ./
COPY dist/apps/holder-backend/pnpm-lock.yaml ./
RUN npm install -g [email protected]
RUN pnpm install --prod

# Production image, copy all the files and run nest
FROM docker.io/node:lts-alpine as runner
RUN apk add --no-cache dumb-init
ENV NODE_ENV production
ENV PORT 3000
WORKDIR /usr/src/app
COPY --from=deps /usr/src/app/node_modules ./node_modules
COPY --from=deps /usr/src/app/package.json ./package.json
COPY dist/apps/holder-backend .
RUN chown -R node:node .
USER node
EXPOSE 3000
CMD ["dumb-init", "node", "main.js"]
29 changes: 0 additions & 29 deletions apps/verifier-backend/old-build-target.json

This file was deleted.

12 changes: 12 additions & 0 deletions apps/verifier-backend/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
"buildTarget": "verifier-backend:build:production"
}
}
},
"container": {
"executor": "@nx-tools/nx-container:build",
"dependsOn": ["build"],
"options": {
"engine": "docker",
"metadata": {
"images": ["ghcr.io/cre8/wallet/verifier-backend"],
"load": true,
"tags": ["latest"]
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class RelyingPartyManagerService {
(field) => field.path[0].slice(2)
);
try {
// biome-ignore lint/style/useConst: <explanation>
// eslint-disable-next-line prefer-const
let sdjwtInstance: SDJwtVcInstance;
/**
* The verifier function. This function will verify the signature of the vc.
Expand Down
Loading

0 comments on commit a07bda2

Please sign in to comment.