-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
117 lines (83 loc) · 2.82 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
# Cache the dependencies of the Dashboard
FROM node:18-bookworm-slim AS dashboard_deps
WORKDIR /app
# Copy the package.json and yarn.lock files to the container
COPY ./dashboard/package.json ./dashboard/yarn.lock ./
# Install dependencies
RUN yarn install --frozen-lockfile
# Now copy all the sources so we can compile
FROM node:18-bookworm-slim AS dashboard_builder
WORKDIR /app
COPY ./dashboard .
COPY --from=dashboard_deps /app/node_modules ./node_modules
# Build the webapp
RUN yarn build --mode production
FROM lukemathwalker/cargo-chef:0.1.66-rust-slim-bookworm AS chef
WORKDIR /app/server
FROM chef AS server_planner
# Copy needed directories
COPY ./server/src /app/server/src
COPY ./server/api /app/server/api
COPY ./server/Cargo.lock /app/server/Cargo.lock
COPY ./server/Cargo.toml /app/server/Cargo.toml
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS server_builder
COPY --from=server_planner /app/server/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --recipe-path recipe.json
# Copy needed directories
COPY ./server/src /app/server/src
COPY ./server/api /app/server/api
COPY ./server/Cargo.lock /app/server/Cargo.lock
COPY ./server/Cargo.toml /app/server/Cargo.toml
# Build the binary
RUN cargo build --release
FROM node:20-bookworm as keiko
ARG DOJO_VERSION
RUN if [ -z "$DOJO_VERSION" ]; then echo "DOJO_VERSION argument is required" && exit 1; fi
# Install dependencies
RUN apt-get update && \
apt-get install -y \
jq \
git-all \
build-essential \
nano \
net-tools \
cargo
RUN apt-get autoremove && apt-get clean
RUN npm i -g @import-meta-env/cli
# Install rust
#RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y
#Install Scarb
RUN curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh --output install.sh
RUN chmod +x ./install.sh
RUN export PATH=$HOME/.local/bin:$PATH && ./install.sh
RUN echo 'export PATH=$HOME/.local/bin:$PATH' >> $HOME/.bashrc
ENV PATH="/root/.local/bin:${PATH}"
# Install dojo
SHELL ["/bin/bash", "-c"]
RUN curl -L https://install.dojoengine.org | bash
RUN source ~/.bashrc
ENV PATH="/root/.dojo/bin:${PATH}"
RUN dojoup -v $DOJO_VERSION
# Install starkli
SHELL ["/bin/bash", "-c"]
RUN curl https://get.starkli.sh | bash
RUN source ~/.bashrc
ENV PATH="/root/.starkli/bin:${PATH}"
RUN starkliup
# TODO copy the dojo_examples, build them
WORKDIR /keiko
# Contracts
COPY ./server/contracts ./contracts
# Warm up the git cache for "sozo build"
RUN cd contracts && sozo build
# Server
COPY --from=server_builder /app/server/target/release/keiko .
COPY ./server/static ./static
# Dashboard
COPY --from=dashboard_builder /app/dist ./static/keiko
COPY ./dashboard/.env.example ./.env.example
ENV PUBLIC_NODE_URL=http://localhost:5050
ENV PROD=true
CMD ["./keiko"]