-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
140 lines (100 loc) · 3.55 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Stage 4: Install runtime
FROM node:22-bookworm-slim AS dojo
SHELL ["/bin/bash", "-c"]
ARG ASDF_VERSION="v0.14.1"
ARG SCARB_VERSION="2.7.0"
ARG DOJO_VERSION="1.0.0"
ARG STARKLI_VERSION="0.1.6"
# Install dependencies
RUN apt-get update && \
apt-get install -y \
jq \
git \
procps \
nano \
net-tools \
sqlite3 \
curl \
build-essential \
make \
zip && \
apt-get autoremove && apt-get clean
RUN yarn global add ts-node pm2
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
#RUN if [ -z "$DOJO_VERSION" ]; then echo "DOJO_VERSION argument is required" && exit 1; fi
RUN \
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch ${ASDF_VERSION} && \
chmod +x $HOME/.asdf/asdf.sh && \
echo "$HOME/.asdf/asdf.sh" >> ~/.bashrc && \
source ~/.bashrc
ENV PATH="/root/.asdf/bin:/root/.asdf/shims:${PATH}"
RUN \
asdf plugin add scarb && \
asdf install scarb ${SCARB_VERSION} && \
asdf global scarb ${SCARB_VERSION}
RUN \
asdf plugin add dojo https://github.com/pixelaw/asdf-dojo && \
asdf install dojo ${DOJO_VERSION} && \
asdf global dojo ${DOJO_VERSION}
# Install starkli
# TODO right now getting 0.1.6 because newer seems not to be compatible with katana's JSON-RPC
SHELL ["/bin/bash", "-c"]
RUN curl https://get.starkli.sh | bash
RUN source ~/.bashrc
ENV PATH="/root/.starkli/bin:${PATH}"
RUN starkliup -v ${STARKLI_VERSION}
# Stage 4: Setup runtime
FROM dojo AS builder
ENV PUBLIC_TORII=http://localhost:8080
ENV STARKNET_RPC=http://localhost:5050
ENV CORE_VERSION=VERSION
ENV VITE_PUBLIC_ETH_CONTRACT_ADDRESS=0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7
HEALTHCHECK CMD curl --fail http://localhost:3000 && \
curl --fail http://localhost:5050 && \
curl --fail http://localhost:8080 || \
exit 1
COPY ./dojo_init /tmp/dojo_init
COPY ./contracts/dojo_dev.toml /tmp/dojo_init
COPY ./contracts/Scarb.toml /tmp/dojo_init
COPY ./contracts/Scarb.lock /tmp/dojo_init
# Remove the test_helpers from the warmup, not necessary and complicating
RUN sed -i '/^pixelaw_test_helpers/d' /tmp/dojo_init/Scarb.toml
# Run build separately to cache the dojo/scarb dependencies
RUN --mount=type=cache,id=scarb_cache,target=/root/.cache/scarb \
cd /tmp/dojo_init && sozo build
RUN mkdir -p /tmp/contracts
RUN mkdir -p /tmp/test_helpers
COPY ./contracts /tmp/contracts
COPY ./test_helpers /tmp/test_helpers
WORKDIR /tmp/contracts
## Generate storage_init
RUN \
--mount=type=cache,id=scarb_cache,target=/root/.cache/scarb \
--mount=type=secret,id=DOJO_KEYSTORE_PASSWORD \
bash scripts/create_snapshot_docker.sh dev
ARG GENERATE_POPULATED_CORE=false
RUN \
--mount=type=cache,id=scarb_cache,target=/root/.cache/scarb \
--mount=type=secret,id=DOJO_KEYSTORE_PASSWORD \
bash scripts/create_snapshot_docker.sh dev-pop ${GENERATE_POPULATED_CORE}
# Stage 2: Put the webapp files in place
FROM ghcr.io/pixelaw/web:0.3.11 AS web
FROM ghcr.io/pixelaw/server:0.3.19 AS server
FROM dojo AS runner
WORKDIR /pixelaw
COPY --from=builder /root/ /root/
COPY --from=builder /pixelaw .
COPY --from=web /app/dist /pixelaw/web/
COPY --from=server /app server/
COPY docker/scripts/ /pixelaw/scripts/
COPY docker/ecosystem.config.js /pixelaw/core/docker/
COPY docker/.env.example /pixelaw/core/docker/
COPY docker/.bashrc /root/
COPY ./tools/ /pixelaw/tools/
RUN mkdir /pixelaw/log
LABEL org.opencontainers.image.description="PixeLAW core container"
EXPOSE 5050
EXPOSE 8080
EXPOSE 3000
CMD ["bash", "./scripts/startup.sh"]