Skip to content

Commit

Permalink
🔧 configure Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Odonno committed Sep 2, 2024
1 parent a81a983 commit 3bcab82
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target
Dockerfile
.dockerignore
.git
.gitignore
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM clux/muslrust:1.77.2-stable as builder
WORKDIR /volume
ADD src src
ADD templates templates
ADD Cargo.toml Cargo.toml
ADD Cargo.lock Cargo.lock
RUN cargo build --release --target x86_64-unknown-linux-musl

This comment has been minimized.

Copy link
@senpro-ingwersenk

senpro-ingwersenk Sep 16, 2024

If you remove --target ..., Cargo should auto-detect the platform you are currently running on. Thus, if you run this on, let's say, ARM64, it'll work just fine.

Example:

diff --git a/Dockerfile b/Dockerfile
index 34cd107..36bbb6f 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,9 +4,10 @@ ADD src src
 ADD templates templates
 ADD Cargo.toml Cargo.toml
 ADD Cargo.lock Cargo.lock
-RUN cargo build --release --target x86_64-unknown-linux-musl
+RUN cargo build --release
+RUN RUSTC_TRIPLE=$(rustc --version --verbose | grep "host:" | awk '{print $2}') cp -v /volume/target/$RUSTC_TRIPLE/release/surrealdb-migrations /volume/target/

 FROM alpine
-COPY --from=builder /volume/target/x86_64-unknown-linux-musl/release/surrealdb-migrations ./surrealdb-migrations
+COPY --from=builder /volume/target/surrealdb-migrations ./surrealdb-migrations
 RUN chmod o+rx ./surrealdb-migrations
-ENTRYPOINT [ "/surrealdb-migrations" ]
\ No newline at end of file
+ENTRYPOINT [ "/surrealdb-migrations" ]

I am going to test that when I come home though...


FROM alpine
COPY --from=builder /volume/target/x86_64-unknown-linux-musl/release/surrealdb-migrations ./surrealdb-migrations
RUN chmod o+rx ./surrealdb-migrations
ENTRYPOINT [ "/surrealdb-migrations" ]

0 comments on commit 3bcab82

Please sign in to comment.