-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
157 lines (125 loc) · 4.32 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
###############################################################
### STAGE 1: Build cheqd studio app ###
###############################################################
FROM node:18-alpine AS builder
# Set working directory
WORKDIR /home/node/app
# Copy source
COPY . .
# Installing dependencies
RUN npm ci
# Build the app
RUN npm run build
###############################################################
### STAGE 2: Build cheqd studio runner ###
###############################################################
FROM node:18-alpine AS runner
# Set Node.js environment
ENV NODE_ENV=production
# Set working directory
WORKDIR /home/node/app
# Install pre-requisites
RUN apk update && \
apk add --no-cache bash ca-certificates
# Copy files from builder
COPY --from=builder --chown=node:node /home/node/app/*.json /home/node/app/*.md ./
COPY --from=builder --chown=node:node /home/node/app/dist ./dist
# Install production dependencies
RUN npm ci
# Base arguments: build-time
ARG NPM_CONFIG_LOGLEVEL=warn
ARG PORT=3000
# Network API endpoints: build-time
ARG MAINNET_RPC_URL=https://rpc.cheqd.net:443
ARG TESTNET_RPC_URL=https://rpc.cheqd.network:443
ARG RESOLVER_URL=https://resolver.cheqd.net/1.0/identifiers/
# Veramo Database configuration: build-time
ARG ENABLE_EXTERNAL_DB=false
ARG EXTERNAL_DB_CONNECTION_URL
ARG EXTERNAL_DB_ENCRYPTION_KEY
ARG EXTERNAL_DB_CERT
# LogTo: build-time
ARG ENABLE_AUTHENTICATION=false
ARG LOGTO_ENDPOINT
ARG LOGTO_DEFAULT_RESOURCE_URL
ARG LOGTO_APP_ID
ARG LOGTO_APP_SECRET
ARG CORS_ALLOWED_ORIGINS
ARG COOKIE_SECRET
ARG LOGTO_M2M_APP_ID
ARG LOGTO_M2M_APP_SECRET
ARG LOGTO_MANAGEMENT_API
ARG LOGTO_TESTNET_ROLE_ID
ARG LOGTO_DEFAULT_ROLE_ID
ARG LOGTO_MAINNET_ROLE_ID
ARG LOGTO_WEBHOOK_SECRET
ARG LOG_LEVEL=info
# API generation
ARG API_KEY_EXPIRATION=30
# Verida connector: build-time
ARG ENABLE_VERIDA_CONNECTOR=false
ARG POLYGON_RPC_URL=https://rpc.ankr.com/polygon_mumbai
ARG VERIDA_PRIVATE_KEY
ARG POLYGON_PRIVATE_KEY
ARG ENABLE_ACCOUNT_TOPUP=false
ARG FAUCET_URI=https://faucet-api.cheqd.network/credit
ARG TESTNET_MINIMUM_BALANCE=1000
# Stripe
ARG STRIPE_ENABLED=false
ARG STRIPE_SECRET_KEY
ARG STRIPE_PUBLISHABLE_KEY
ARG STRIPE_WEBHOOK_SECRET
# Environment variables: base configuration
ENV NPM_CONFIG_LOGLEVEL ${NPM_CONFIG_LOGLEVEL}
ENV PORT ${PORT}
# Environment variables: network API endpoints
ENV MAINNET_RPC_URL ${MAINNET_RPC_URL}
ENV TESTNET_RPC_URL ${TESTNET_RPC_URL}
ENV RESOLVER_URL ${RESOLVER_URL}
ENV APPLICATION_BASE_URL ${APPLICATION_BASE_URL}
# Environment variables: Veramo Database configuration
ENV ENABLE_EXTERNAL_DB ${ENABLE_EXTERNAL_DB}
ENV EXTERNAL_DB_CONNECTION_URL ${EXTERNAL_DB_CONNECTION_URL}
ENV EXTERNAL_DB_ENCRYPTION_KEY ${EXTERNAL_DB_ENCRYPTION_KEY}
ENV EXTERNAL_DB_CERT ${EXTERNAL_DB_CERT}
# Environment variables: LogTo
ENV ENABLE_AUTHENTICATION ${ENABLE_AUTHENTICATION}
ENV LOGTO_ENDPOINT ${LOGTO_ENDPOINT}
ENV LOGTO_DEFAULT_RESOURCE_URL ${LOGTO_DEFAULT_RESOURCE_URL}
ENV LOGTO_APP_ID ${LOGTO_APP_ID}
ENV LOGTO_APP_SECRET ${LOGTO_APP_SECRET}
ENV CORS_ALLOWED_ORIGINS ${CORS_ALLOWED_ORIGINS}
ENV COOKIE_SECRET ${COOKIE_SECRET}
ENV LOGTO_M2M_APP_ID ${LOGTO_M2M_APP_ID}
ENV LOGTO_M2M_APP_SECRET ${LOGTO_M2M_APP_SECRET}
ENV LOGTO_MANAGEMENT_API ${LOGTO_MANAGEMENT_API}
ENV LOGTO_TESTNET_ROLE_ID ${LOGTO_TESTNET_ROLE_ID}
ENV LOGTO_DEFAULT_ROLE_ID ${LOGTO_DEFAULT_ROLE_ID}
ENV LOGTO_MAINNET_ROLE_ID ${LOGTO_MAINNET_ROLE_ID}
ENV LOGTO_WEBHOOK_SECRET ${LOGTO_WEBHOOK_SECRET}
ENV LOG_LEVEL ${LOG_LEVEL}
# API generatioin
ENV API_KEY_EXPIRATION ${API_KEY_EXPIRATION}
# Faucet setup
ENV ENABLE_ACCOUNT_TOPUP ${ENABLE_ACCOUNT_TOPUP}
ENV FAUCET_URI ${FAUCET_URI}
ENV TESTNET_MINIMUM_BALANCE ${TESTNET_MINIMUM_BALANCE}
# Environment variables: Verida connector
ENV ENABLE_VERIDA_CONNECTOR ${ENABLE_VERIDA_CONNECTOR}
ENV POLYGON_RPC_URL ${POLYGON_RPC_URL}
ENV VERIDA_PRIVATE_KEY ${VERIDA_PRIVATE_KEY}
ENV POLYGON_PRIVATE_KEY ${POLYGON_PRIVATE_KEY}
# Environment variables: Stripe
ENV STRIPE_SECRET_KEY ${STRIPE_SECRET_KEY}
ENV STRIPE_PUBLISHABLE_KEY ${STRIPE_PUBLISHABLE_KEY}
ENV STRIPE_WEBHOOK_SECRET ${STRIPE_WEBHOOK_SECRET}
ENV STRIPE_ENABLED ${STRIPE_ENABLED}
# Set ownership permissions
RUN chown -R node:node /home/node/app
# Specify default port
EXPOSE ${PORT}
# Set user and shell
USER node
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
# Run the application
CMD ["npm", "start"]