|
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" |
| 1 | +FROM --platform=amd64 487920318758.dkr.ecr.eu-central-1.amazonaws.com/cljs-web3-ci:node-20.18.1 as builder |
| 2 | +ARG ETHLANCE_ENV |
| 3 | +ARG ETHLANCE_DEPLOY_SEED |
4 | 4 | USER root |
5 | 5 |
|
6 | | -ENV ETHLANCE_COMPONENT="ui" |
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}" |
12 | | -ENV SMART_CONTRACTS_PATH="/build/ethlance/shared/src/ethlance/shared/smart_contracts_${BUILD_ENV}.cljs" |
13 | | -ENV SMART_CONTRACTS_BUILD_PATH="/build/ethlance/resources/public/contracts/build" |
14 | | -ENV ETHLANCE_CONFIG_PATH="/build/ethlance/config/${ETHLANCE_COMPONENT}-config-${BUILD_ENV}.edn" |
15 | | - |
16 | | -WORKDIR /build/ethlance |
| 6 | +# Set environment variables |
| 7 | +ENV ETHLANCE_SOURCE_ROOT=/build/ethlance \ |
| 8 | + ETHLANCE_ENV=$ETHLANCE_ENV |
| 9 | +ENV ETHLANCE_SERVER_ROOT=${ETHLANCE_SOURCE_ROOT}/server \ |
| 10 | + ETHLANCE_DEPLOY_SEED=${ETHLANCE_DEPLOY_SEED} \ |
| 11 | + SMART_CONTRACTS_BUILD_PATH="${ETHLANCE_SOURCE_ROOT}/resources/public/contracts/build" \ |
| 12 | + SMART_CONTRACTS_PATH="${ETHLANCE_SOURCE_ROOT}/shared/src/ethlance/shared/smart_contracts_${ETHLANCE_ENV}.cljs" \ |
| 13 | + ETHLANCE_CONFIG_PATH="${ETHLANCE_SOURCE_ROOT}/config/server-config-${ETHLANCE_ENV}.edn" \ |
| 14 | + UI_CONFIG_PATH="${ETHLANCE_SOURCE_ROOT}/config/ui-config-${ETHLANCE_ENV}.edn" |
| 15 | + |
| 16 | +# Set working directory and prepare source files |
| 17 | +WORKDIR ${ETHLANCE_SOURCE_ROOT} |
17 | 18 | COPY . . |
| 19 | +COPY ethlance-config/config "${ETHLANCE_SOURCE_ROOT}/config" |
18 | 20 |
|
19 | | -RUN cat "${SMART_CONTRACTS_PATH}" |
| 21 | +# Clone required dependencies |
| 22 | +RUN git clone --depth 1 https://github.com/district0x/d0x-libs /build/d0x-libs |
20 | 23 |
|
21 | | -# WORKDIR /build/ethlance-config |
22 | | -# COPY config . |
| 24 | +# Build stage - compile contracts and UI |
| 25 | +# Compile contracts |
| 26 | +RUN yarn install && ETHLANCE_ENV="${ETHLANCE_ENV}" npx truffle compile |
23 | 27 |
|
24 | | -WORKDIR /build |
25 | | -COPY ethlance-config/config /build/ethlance/config |
26 | | -RUN git clone https://github.com/district0x/d0x-libs |
27 | | - |
28 | | - |
29 | | -ARG BUILD_ENV=qa |
30 | | -ARG ETHLANCE_ENV=qa |
31 | | -FROM init as build_stage |
32 | | -ENV ETHLANCE_ENV=qa |
33 | | -WORKDIR $ETHLANCE_SOURCE_ROOT |
34 | | -RUN yarn install && ETHLANCE_ENV="${BUILD_ENV}" npx truffle compile |
35 | | - |
36 | | -WORKDIR $ETHLANCE_SOURCE_ROOT/ui |
| 28 | +# Build UI components |
| 29 | +WORKDIR ${ETHLANCE_SOURCE_ROOT}/ui |
37 | 30 | RUN yarn install && \ |
38 | | - ETHLANCE_ENV="${BUILD_ENV}" npx shadow-cljs release dev-ui && \ |
| 31 | + ETHLANCE_ENV="${ETHLANCE_ENV}" npx shadow-cljs release dev-ui && \ |
39 | 32 | ./node_modules/less/bin/lessc resources/public/less/main.less resources/public/css/main.css --verbose |
40 | 33 |
|
| 34 | +# Final stage - using nginx to serve the UI |
41 | 35 | FROM nginx:alpine |
42 | | -ENV ETHLANCE_ENV=qa |
| 36 | +ARG ETHLANCE_ENV |
| 37 | +ENV ETHLANCE_ENV=$ETHLANCE_ENV |
43 | 38 |
|
| 39 | +# Configure nginx |
44 | 40 | COPY docker-builds/ui/ethlance.conf /etc/nginx/conf.d/ |
45 | 41 | COPY docker-builds/ui/default.conf /etc/nginx/conf.d/default.conf |
46 | 42 | COPY docker-builds/ui/nginx.conf /etc/nginx/nginx.conf |
47 | 43 |
|
48 | | -COPY --from=build_stage /build/ethlance/resources /deploy/resources |
49 | | -COPY --from=build_stage /build/ethlance/resources/public/contracts /deploy/ui/contracts/ |
50 | | -COPY --from=build_stage /build/ethlance/ui/resources/public /deploy/ui/ |
| 44 | +# Copy built assets from builder stage |
| 45 | +COPY --from=builder /build/ethlance/resources /deploy/resources |
| 46 | +COPY --from=builder /build/ethlance/resources/public/contracts /deploy/ui/contracts/ |
| 47 | +COPY --from=builder /build/ethlance/ui/resources/public /deploy/ui/ |
51 | 48 |
|
52 | 49 | EXPOSE 80 |
0 commit comments