Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions deployment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ RUN cargo chef prepare --recipe-path recipe.json

FROM chef as builder

# Install the latest 20 versions of forc with cargo-binstall
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
RUN tags=$(curl -s "https://api.github.com/repos/FuelLabs/sway/tags?per_page=20" | grep '"name"' | sed -E 's/.*"name": "v?([^"]+)".*/\1/') && \
echo "Tags fetched from the repository:" && \
for tag in $tags; do \
echo "Tag: $tag" && \
cargo binstall --no-confirm --root "/usr/local/cargo/bin/forc-$tag" --pkg-url="https://github.com/FuelLabs/sway/releases/download/v$tag/forc-binaries-linux_arm64.tar.gz" --bin-dir="forc-binaries/forc" --pkg-fmt="tgz" forc; \
done

ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
COPY --from=planner /build/recipe.json recipe.json
# Build our project dependecies, not our application!
Expand All @@ -38,7 +29,7 @@ COPY . .
RUN cargo build

# Stage 2: Run
FROM ubuntu:22.04 as run
FROM rust:1.84 as run

RUN apt-get update -y \
&& apt-get install -y --no-install-recommends ca-certificates curl git libpq5 \
Expand All @@ -47,9 +38,17 @@ RUN apt-get update -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

# Install the latest 20 versions of forc with cargo-binstall
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
RUN tags=$(curl -s "https://api.github.com/repos/FuelLabs/sway/tags?per_page=20" | grep '"name"' | sed -E 's/.*"name": "v?([^"]+)".*/\1/') && \
echo "Tags fetched from the repository:" && \
for tag in $tags; do \
echo "Tag: $tag" && \
cargo binstall --no-confirm --root "forc-$tag" --pkg-url="https://github.com/FuelLabs/sway/releases/download/v$tag/forc-binaries-linux_arm64.tar.gz" --bin-dir="forc-binaries/forc" --pkg-fmt="tgz" forc; \
done

WORKDIR /root/

COPY --from=builder /usr/local/cargo/bin/forc-* .
COPY --from=builder /build/target/debug/forc_pub .
COPY --from=builder /build/target/debug/forc_pub.d .
COPY --from=builder /build/Rocket.toml .
Expand Down
5 changes: 4 additions & 1 deletion src/handlers/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,10 @@ pub fn install_forc_at_path(forc_version: &str, forc_path: &Path) -> Result<(),
.arg("--pkg-fmt=tgz")
.arg(format!("forc@{forc_version}"))
.output()
.map_err(|_| UploadError::InvalidForcVersion(forc_version.to_string()))?;
.map_err(|err| {
error!("Failed to install forc with binstall: {:?}", err);
UploadError::InvalidForcVersion(forc_version.to_string())
})?;

if !output.status.success() {
error!("Failed to install forc: {:?}", output);
Expand Down
Loading