|
1 | | -FROM --platform=amd64 487920318758.dkr.ecr.us-west-2.amazonaws.com/cljs-web3-ci:node-20.18.1 as init |
2 | | -ARG BUILD_ENV=qa |
3 | | -ARG ETHLANCE_DEPLOY_SEED="sign bachelor state zoo expire boat morning situate scene unveil oven crew" |
4 | | -USER root |
| 1 | +ARG DOCKER_REGISTRY |
| 2 | +FROM $DOCKER_REGISTRY/cljs-web3-ci:node-20.18.1 AS builder |
5 | 3 |
|
6 | | -ENV ETHLANCE_COMPONENT="server" |
7 | | -ENV ETHLANCE_SOURCE_ROOT=/build/ethlance |
8 | | -ENV ETHLANCE_SERVER_ROOT=/build/ethlance/server |
9 | | -ENV ETHLANCE_ENV=$BUILD_ENV |
10 | | -ENV DEPLOY_TARGET=/deploy/ |
11 | | -ENV ETHLANCE_DEPLOY_SEED=${ETHLANCE_DEPLOY_SEED} |
| 4 | +ARG ETHLANCE_ENV |
| 5 | +ARG ETHLANCE_DEPLOY_SEED |
| 6 | +USER root |
12 | 7 |
|
13 | | -ENV SMART_CONTRACTS_PATH="/build/ethlance/shared/src/ethlance/shared/smart_contracts_${BUILD_ENV}.cljs" |
14 | | -ENV SMART_CONTRACTS_BUILD_PATH="/build/ethlance/resources/public/contracts/build" |
15 | | -ENV ETHLANCE_CONFIG_PATH="/build/ethlance/config/${ETHLANCE_COMPONENT}-config-${BUILD_ENV}.edn" |
16 | | -ENV UI_CONFIG_PATH="/build/ethlance/config/ui-config-${BUILD_ENV}.edn" |
| 8 | +# Set environment variables |
| 9 | +ENV ETHLANCE_SOURCE_ROOT=/build/ethlance \ |
| 10 | + ETHLANCE_ENV=$ETHLANCE_ENV \ |
| 11 | + BUILD_ENV=$ETHLANCE_ENV |
| 12 | +ENV ETHLANCE_SERVER_ROOT=${ETHLANCE_SOURCE_ROOT}/server \ |
| 13 | + ETHLANCE_DEPLOY_SEED=${ETHLANCE_DEPLOY_SEED} \ |
| 14 | + SMART_CONTRACTS_BUILD_PATH="${ETHLANCE_SOURCE_ROOT}/resources/public/contracts/build" \ |
| 15 | + SMART_CONTRACTS_PATH="${ETHLANCE_SOURCE_ROOT}/shared/src/ethlance/shared/smart_contracts_${ETHLANCE_ENV}.cljs" \ |
| 16 | + ETHLANCE_CONFIG_PATH="${ETHLANCE_SOURCE_ROOT}/config/server-config-${ETHLANCE_ENV}.edn" \ |
| 17 | + UI_CONFIG_PATH="${ETHLANCE_SOURCE_ROOT}/config/ui-config-${ETHLANCE_ENV}.edn" |
17 | 18 |
|
18 | | -WORKDIR /build/ethlance |
| 19 | +WORKDIR ${ETHLANCE_SOURCE_ROOT} |
19 | 20 | COPY . . |
| 21 | +COPY ethlance-config/config "${ETHLANCE_SOURCE_ROOT}/config" |
20 | 22 |
|
21 | | -RUN cat "${SMART_CONTRACTS_PATH}" |
| 23 | +# Clone required libraries |
| 24 | +RUN git clone --depth 1 https://github.com/district0x/d0x-libs /build/d0x-libs |
22 | 25 |
|
23 | | -# WORKDIR /build/ethlance-config/ |
24 | | -# COPY ethlance-config . |
25 | | -WORKDIR /build |
26 | | -COPY ethlance-config/config /build/ethlance/config |
27 | | -# RUN cp /build/ethlance/ethlance-config/config /build/ethlance/ |
28 | | -RUN git clone https://github.com/district0x/d0x-libs |
29 | | - |
30 | | -FROM init as build_server |
31 | | -WORKDIR ${ETHLANCE_SOURCE_ROOT} |
32 | | -RUN yarn install && ETHLANCE_ENV="${BUILD_ENV}" npx truffle compile |
| 26 | +# Compile contracts |
| 27 | +RUN yarn install && ETHLANCE_ENV="${ETHLANCE_ENV}" npx truffle compile |
33 | 28 |
|
34 | | -# Release deployment |
| 29 | +# Build UI |
35 | 30 | WORKDIR "${ETHLANCE_SOURCE_ROOT}/ui" |
36 | 31 | RUN yarn && \ |
37 | | - ETHLANCE_ENV="${BUILD_ENV}" npx shadow-cljs release dev-ui && \ |
| 32 | + ETHLANCE_ENV="${ETHLANCE_ENV}" npx shadow-cljs release dev-ui && \ |
38 | 33 | ./node_modules/less/bin/lessc resources/public/less/main.less resources/public/css/main.css --verbose |
39 | 34 |
|
40 | | -# Release deployment |
| 35 | +# Build server |
41 | 36 | WORKDIR "${ETHLANCE_SOURCE_ROOT}/server" |
42 | 37 | RUN yarn && npx shadow-cljs release dev-server |
43 | 38 |
|
44 | | -ARG BUILD_ENV=qa |
45 | | -ARG ETHLANCE_ENV=qa |
46 | | -FROM node:20 |
47 | | -ENV ETHLANCE_SOURCE_ROOT=/deploy |
48 | | -ENV ETHLANCE_SERVER_ROOT=/deploy/server |
49 | | -ENV ETHLANCE_ENV=qa |
50 | | -ENV DEPLOY_TARGET=/deploy |
51 | | -ENV UI_CONFIG_PATH="/deploy/resources/config/ui-config-${BUILD_ENV}.edn" |
52 | | -ENV SERVER_CONFIG_PATH="/deploy/resources/config/server-config-${BUILD_ENV}.edn" |
53 | | -WORKDIR "${ETHLANCE_SERVER_ROOT}" |
54 | | - |
55 | | -COPY --from=build_server /build/ethlance/config/ui-config-${ETHLANCE_ENV}.edn /deploy/resources/config/ui-config-${ETHLANCE_ENV}.edn |
56 | | -COPY --from=build_server /build/ethlance/config/server-config-${ETHLANCE_ENV}.edn /deploy/resources/config/server-config-${ETHLANCE_ENV}.edn |
57 | | -COPY --from=build_server /build/ethlance/resources /deploy/resources |
58 | | -COPY --from=build_server /build/ethlance/server/node_modules /deploy/server/node_modules/ |
59 | | -COPY --from=build_server /build/ethlance/server/package.json /build/ethlance/server/out/ethlance_server* /deploy/server/ |
60 | | -COPY --from=build_server /build/ethlance/resources/public/contracts /deploy/ui/contracts/ |
61 | | -COPY --from=build_server /build/ethlance/ui/resources/public/* /deploy/ui/ |
62 | | -RUN echo -n "{:last-processed-block 9622279}" > ethlance-events.log |
63 | | -CMD [ "node", "ethlance_server.js" ] |
| 39 | +# Final stage - minimal runtime image |
| 40 | +FROM node:20-slim |
| 41 | +ARG ETHLANCE_ENV |
| 42 | +ENV ETHLANCE_ENV=$ETHLANCE_ENV \ |
| 43 | + ETHLANCE_SOURCE_ROOT=/build/ethlance |
| 44 | +ENV ETHLANCE_SERVER_ROOT=/build/ethlance/server \ |
| 45 | + SMART_CONTRACTS_BUILD_PATH="${ETHLANCE_SOURCE_ROOT}/resources/public/contracts/build" \ |
| 46 | + SMART_CONTRACTS_PATH="${ETHLANCE_SOURCE_ROOT}/shared/src/ethlance/shared/smart_contracts_${ETHLANCE_ENV}.cljs" \ |
| 47 | + UI_CONFIG_PATH="/build/ethlance/config/ui-config-prod.edn" \ |
| 48 | + ETHLANCE_CONFIG_PATH="/build/ethlance/config/server-config-prod.edn" |
| 49 | + |
| 50 | +WORKDIR ${ETHLANCE_SERVER_ROOT} |
| 51 | + |
| 52 | +COPY --from=builder /build /build |
| 53 | +# Initialize events log |
| 54 | +RUN echo -n "{:last-processed-block 27409455}" > ethlance-events.log |
| 55 | + |
| 56 | +EXPOSE 6300 |
| 57 | +CMD ["node", "out/ethlance_server.js"] |
0 commit comments