forked from cheqd/did-registrar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
61 lines (45 loc) · 1.48 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
###############################################################
### STAGE 1: Build did-registrar app ###
###############################################################
FROM node:18-alpine AS builder
# Set working directory & bash defaults
WORKDIR /home/node/app
# Copy source files
COPY . .
# Installing dependencies
RUN npm ci
# Build the app
RUN npm run build
###############################################################
### STAGE 2: Run did-registar app ###
###############################################################
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=3000
ARG FEE_PAYER_TESTNET_MNEMONIC
ARG FEE_PAYER_MAINNET_MNEMONIC
# NPM environment variables
ENV NODE_ENV ${NODE_ENV}
ENV NPM_CONFIG_LOGLEVEL ${NPM_CONFIG_LOGLEVEL}
ENV PORT ${PORT}
# App-specific environment variables
ENV FEE_PAYER_TESTNET_MNEMONIC ${FEE_PAYER_TESTNET_MNEMONIC}
ENV FEE_PAYER_MAINNET_MNEMONIC ${FEE_PAYER_MAINNET_MNEMONIC}
# Install pre-requisites
RUN npm install [email protected] && \
chown -R node:node /home/node/app && \
apk update && \
apk add --no-cache bash ca-certificates
# Specify default port
EXPOSE ${PORT}
# Set user and shell
USER node
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
# Run the application
CMD [ "node", "index.js" ]