Skip to content

Commit

Permalink
build: Fix migration creation
Browse files Browse the repository at this point in the history
  • Loading branch information
DaevMithran committed May 11, 2023
1 parent beb0bb1 commit 7ead2d2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 40 deletions.
43 changes: 7 additions & 36 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###############################################################
### STAGE 1: Build credential-service app ###
###############################################################
######################################################
### Build credential-service app ###
######################################################

FROM node:18-alpine AS builder

Expand All @@ -13,33 +13,11 @@ COPY . .
# Installing dependencies
RUN npm ci

ARG ISSUER_DATABASE_URL
ENV ISSUER_DATABASE_URL ${ISSUER_DATABASE_URL}

# create migrations
RUN npm run migration

# Build the app
RUN npm run build

###############################################################
### STAGE 2: Build runner ###
###############################################################

FROM node:18-alpine AS runner

# Set working directory & bash defaults
WORKDIR /home/node/app

# Copy built application
COPY --from=builder /home/node/app/dist .

# Build-time arguments
ARG NODE_ENV=production
ARG NPM_CONFIG_LOGLEVEL=warn
ARG PORT=8787
ARG ISSUER_SECRET_KEY
ARG ISSUER_DATABASE_SYNCHRONIZE
ARG ISSUER_DATABASE_URL
ARG MAINNET_RPC_URL
ARG TESTNET_RPC_URL
Expand All @@ -57,22 +35,15 @@ ENV TESTNET_RPC_URL ${TESTNET_RPC_URL}
ENV RESOLVER_URL ${RESOLVER_URL}
ENV ALLOWED_ORIGINS ${ALLOWED_ORIGINS}

# We don't have the node_modules directory
# this image only has the output worker.js file.
# Install pre-requisites
RUN npm install swagger-ui-express@4.5.0 && \
chown -R node:node /home/node/app && \
apk update && \
apk add --no-cache bash ca-certificates python3 build-base gcc g++ postgresql-dev

RUN npm i pg-native
# Build the app
RUN npm run build

# Specify default port
EXPOSE ${PORT}

# Set user and shell
USER node
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
SHELL ["/bin/sh", "-euo", "pipefail", "-c"]

# Run the application
CMD [ "node", "index.js" ]
CMD npm run migration; node dist/index.js
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lint": "eslint --max-warnings=0 src && prettier --check '*.{json,js}' 'src/**/*.{js,ts}' 'test/**/*.{js,ts}'",
"test": "jest --config jestconfig.json --verbose",
"typeorm": "typeorm-ts-node-commonjs -d ./src/database/ormconfig.ts",
"migration": "npm run typeorm migration:generate ./migrations && npm run typeorm migration:run"
"migration": "npm run typeorm migration:generate . && npm run typeorm migration:run"
},
"eslintConfig": {
"root": true,
Expand Down
3 changes: 0 additions & 3 deletions src/types/environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ declare global {
RESOLVER_URL: string
ALLOWED_ORIGINS: string | undefined
ISSUER_DATABASE_URL: string
ISSUER_DATABASE_SYNCHRONIZE: string
ISSUER_SECRET_KEY: string
FEE_PAYER_MNEMONIC_MAINNET: string
FEE_PAYER_MNENONIC_TESTNET: string
}
}
}
Expand Down

0 comments on commit 7ead2d2

Please sign in to comment.