-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Change Dockerfile for minimal docker image with scratch Signed-off-by: RagnarokMew <[email protected]> * Restore old Dockerfile and move new one to Dockerfile_from_scratch Signed-off-by: RagnarokMew <[email protected]> --------- Signed-off-by: RagnarokMew <[email protected]>
- Loading branch information
1 parent
48b4769
commit 72a7b39
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
################ | ||
##### Builder | ||
FROM alpine:3.19.1 AS builder | ||
|
||
RUN apk update && apk upgrade && apk add binutils build-base ca-certificates curl file g++ gcc make patch fuse3 | ||
|
||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
|
||
RUN . ~/.cargo/env && rustup target add x86_64-unknown-linux-musl | ||
|
||
RUN . ~/.cargo/env && rustup default nightly && rustup update | ||
|
||
# Cache downloaded+built dependencies | ||
#COPY Cargo.toml Cargo.lock /usr/src/rencfs/ | ||
#RUN mkdir /usr/src/rencfs/src && \ | ||
# echo 'fn main() {}' > /usr/src/rencfs/src/main.rs | ||
# | ||
#RUN . ~/.cargo/env && cd /usr/src/rencfs/ && cargo build --release && \ | ||
# rm -Rvf /usr/src/rencfs/src | ||
|
||
# Build our actual code | ||
#COPY Cargo.toml Cargo.lock /usr/src/rencfs/ | ||
#COPY src /usr/src/rencfs | ||
COPY . /usr/src/rencfs | ||
#COPY examples /usr/src/rencfs/examples | ||
RUN . ~/.cargo/env && \ | ||
cd /usr/src/rencfs/ && \ | ||
cargo build --target x86_64-unknown-linux-musl --release | ||
|
||
#Copy the fusermount3 binary and libraries into a directory | ||
RUN mkdir /fusermount3dep && \ | ||
cp $(which fusermount3) /fusermount3dep/ && \ | ||
ldd $(which fusermount3) | awk '{ print $3 }' | xargs -I {} cp {} /fusermount3dep/ | ||
|
||
|
||
################ | ||
##### Runtime | ||
FROM scratch AS runtime | ||
|
||
# Copy fusermount3 | ||
COPY --from=builder /fusermount3dep/fusermount3 /usr/bin/ | ||
|
||
# Copy busybox | ||
COPY --from=builder /bin/ /bin/ | ||
|
||
# Copy ld-musl (fusermount3 & busybox dep) | ||
COPY --from=builder /fusermount3dep/ld* /lib/ | ||
|
||
# Copy application binary from builder image | ||
COPY --from=builder /usr/src/rencfs/target/x86_64-unknown-linux-musl/release/rencfs /usr/bin/ | ||
|
||
# Run the application | ||
CMD ["rencfs", "--help"] |