-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
86 lines (79 loc) · 3.08 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
# Install dependencies only when needed
FROM node:lts AS deps
WORKDIR /opt/app
COPY *.json ./
RUN npm ci
# Rebuild the source code only when needed
# This is where because may be the case that you would try
# to build the app based on some `X_TAG` in my case (Git commit hash)
# but the code hasn't changed.
FROM node:18 AS builder
WORKDIR /opt/app
COPY . .
COPY --from=deps /opt/app/node_modules ./node_modules
ARG NEXT_PUBLIC_FAIROSHOST
ENV NEXT_PUBLIC_FAIROSHOST=$NEXT_PUBLIC_FAIROSHOST
ARG NEXT_PUBLIC_ENVIRONMENT
ENV NEXT_PUBLIC_ENVIRONMENT=$NEXT_PUBLIC_ENVIRONMENT
ARG NEXT_PUBLIC_FAIRDRIVEHOST
ENV NEXT_PUBLIC_FAIRDRIVEHOST=$NEXT_PUBLIC_FAIRDRIVEHOST
ARG NEXT_PUBLIC_NAME
ENV NEXT_PUBLIC_NAME=$NEXT_PUBLIC_NAME
ARG NEXT_PUBLIC_ETHERNA_INDEX_API_PATH
ENV NEXT_PUBLIC_ETHERNA_INDEX_API_PATH=$NEXT_PUBLIC_ETHERNA_INDEX_API_PATH
ARG NEXT_PUBLIC_BEE_URL
ENV NEXT_PUBLIC_BEE_URL=$NEXT_PUBLIC_BEE_URL
ARG NEXT_PUBLIC_BB_RULES_URL
ENV NEXT_PUBLIC_BB_RULES_URL=$NEXT_PUBLIC_BB_RULES_URL
ARG NEXT_PUBLIC_BB_API_URL
ENV NEXT_PUBLIC_BB_API_URL=$NEXT_PUBLIC_BB_API_URL
ARG NEXT_PUBLIC_BEE_DEBUG_URL
ENV NEXT_PUBLIC_BEE_DEBUG_URL=$NEXT_PUBLIC_BEE_DEBUG_URL
ARG NEXT_PUBLIC_CREATE_ACCOUNT_REDIRECT
ENV NEXT_PUBLIC_CREATE_ACCOUNT_REDIRECT=$NEXT_PUBLIC_CREATE_ACCOUNT_REDIRECT
ARG NEXT_PUBLIC_NFT_GENERATOR_URL
ENV NEXT_PUBLIC_NFT_GENERATOR_URL=$NEXT_PUBLIC_NFT_GENERATOR_URL
ARG NEXT_PUBLIC_GLOBAL_BATCH_ID
ENV NEXT_PUBLIC_GLOBAL_BATCH_ID=$NEXT_PUBLIC_GLOBAL_BATCH_ID
ARG NEXT_PUBLIC_BLOSSOM_ID
ENV NEXT_PUBLIC_BLOSSOM_ID=$NEXT_PUBLIC_BLOSSOM_ID
ARG NEXT_PUBLIC_RPC_URL
ENV NEXT_PUBLIC_RPC_URL=$NEXT_PUBLIC_RPC_URL
ARG NEXT_PUBLIC_ENS_REGISTRY_ADDRESS
ENV NEXT_PUBLIC_ENS_REGISTRY_ADDRESS=$NEXT_PUBLIC_ENS_REGISTRY_ADDRESS
ARG NEXT_PUBLIC_ENS_REGISTRY_ADDRESS
ENV NEXT_PUBLIC_ENS_REGISTRY_ADDRESS=$NEXT_PUBLIC_ENS_REGISTRY_ADDRESS
ARG NEXT_PUBLIC_PUBLIC_RESOLVER_ADDRESS
ENV NEXT_PUBLIC_PUBLIC_RESOLVER_ADDRESS=$NEXT_PUBLIC_PUBLIC_RESOLVER_ADDRESS
ARG NEXT_PUBLIC_SUBDOMAIN_REGISTRAR_ADDRESS
ENV NEXT_PUBLIC_SUBDOMAIN_REGISTRAR_ADDRESS=$NEXT_PUBLIC_SUBDOMAIN_REGISTRAR_ADDRESS
ARG HOST
ENV HOST=$HOST
ARG PORT
ENV PORT=$PORT
SHELL ["/bin/bash", "-eo", "pipefail", "-c"]
RUN env |grep 'NEXT\|HOST\|PORT' > .env
RUN npm run build
# Production image, copy all the files and run next
#FROM node:lts-alpine AS runner
#
#WORKDIR /opt/app
#COPY --from=builder /opt/app/next.config.js ./
#COPY --from=builder /opt/app/public ./public
#COPY --from=builder /opt/app/.next ./.next
#COPY --from=builder /opt/app/node_modules ./node_modules
#
#EXPOSE ${PORT}
#
#CMD ["node_modules/.bin/next", "start"]
#webserver
FROM nginx:stable-alpine
COPY --from=builder /opt/app/out /usr/share/nginx/html
RUN chown -R nginx /usr/share/nginx/html
RUN echo "real_ip_header X-Forwarded-For;" \
"real_ip_recursive on;" \
"set_real_ip_from 0.0.0.0/0;" > /etc/nginx/conf.d/ip.conf
RUN sed -i '/index index.html index.htm/c\ try_files $uri $uri/ /index.html =404;' /etc/nginx/conf.d/default.conf
RUN if [ -f /usr/share/nginx/html/404.html ]; then sed -i 's/#error_page/error_page/g' /etc/nginx/conf.d/default.conf; fi
EXPOSE ${PORT}
CMD ["nginx", "-g", "daemon off;"]