FROM const-gen AS const-export
# This is a multi-stage docker file:
#  1. The first stage contains the built contracts (wasm files)
#  2. The second creates a node.js environment to deploy the contracts to devnet

#  local cosmwasm image, built by tilt
FROM cosmwasm_artifacts AS artifacts

# Contract deployment stage
FROM node:16-buster-slim@sha256:93c9fc3550f5f7d159f282027228e90e3a7f8bf38544758024f005e82607f546

RUN apt update && apt install netcat curl jq -y

WORKDIR /app/tools

COPY --from=artifacts / /app/artifacts

COPY ./tools/package.json ./tools/package-lock.json /app/tools/
RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
    npm ci
COPY ./tools /app/tools
COPY --from=const-export .env /app/tools/.env
