-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b933674
commit 77549dd
Showing
3 changed files
with
67 additions
and
47 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 |
---|---|---|
@@ -1,55 +1,19 @@ | ||
# --------------------------------------------------- | ||
# 1 - Build Stage | ||
# | ||
# Use official rust image to for application build | ||
# --------------------------------------------------- | ||
FROM rust:1.68.2 as build | ||
|
||
# Setup working directory | ||
FROM rust:1.69 as builder | ||
WORKDIR /usr/src/bookstore | ||
COPY . . | ||
|
||
# Install dependency (Required by diesel) | ||
RUN apt-get update && apt-get install libpq5 -y | ||
|
||
# Build application | ||
RUN cargo install --path . | ||
|
||
# --------------------------------------------------- | ||
# 2 - Deploy Stage | ||
# | ||
# Use a distroless image for minimal container size | ||
# - Copy `libpq` dependencies into the image (Required by diesel) | ||
# - Copy application files into the image | ||
# --------------------------------------------------- | ||
FROM gcr.io/distroless/cc-debian11 | ||
FROM debian:bullseye-slim | ||
|
||
# Set the architecture argument (arm64, i.e. aarch64 as default) | ||
# For amd64, i.e. x86_64, you can append a flag when invoking the build `... --build-arg "ARCH=x86_64"` | ||
# ARG ARCH=aarch64 | ||
ARG ARCH=x86_64 | ||
|
||
# libpq related (required by diesel) | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libpq.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libgssapi_krb5.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libldap_r-2.4.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libkrb5.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libk5crypto.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libkrb5support.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/liblber-2.4.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libsasl2.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libgnutls.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libp11-kit.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libidn2.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libunistring.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libtasn1.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libnettle.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libhogweed.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libgmp.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libffi.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /lib/${ARCH}-linux-gnu/libcom_err.so* /lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /lib/${ARCH}-linux-gnu/libkeyutils.so* /lib/${ARCH}-linux-gnu/ | ||
|
||
# Application files | ||
COPY --from=build /usr/local/cargo/bin/bookstore /usr/local/bin/bookstore | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
gcc \ | ||
libc6-dev \ | ||
libpq-dev \ | ||
wget && rm -rf /var/lib/apt/lists/* | ||
COPY --from=builder /usr/local/cargo/bin/bookstore /usr/local/bin/bookstore | ||
EXPOSE 3000 | ||
CMD ["bookstore"] |
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,55 @@ | ||
# --------------------------------------------------- | ||
# 1 - Build Stage | ||
# | ||
# Use official rust image to for application build | ||
# --------------------------------------------------- | ||
FROM rust:1.68.2 as build | ||
|
||
# Setup working directory | ||
WORKDIR /usr/src/bookstore | ||
COPY . . | ||
|
||
# Install dependency (Required by diesel) | ||
RUN apt-get update && apt-get install libpq5 -y | ||
|
||
# Build application | ||
RUN cargo install --path . | ||
|
||
# --------------------------------------------------- | ||
# 2 - Deploy Stage | ||
# | ||
# Use a distroless image for minimal container size | ||
# - Copy `libpq` dependencies into the image (Required by diesel) | ||
# - Copy application files into the image | ||
# --------------------------------------------------- | ||
FROM gcr.io/distroless/cc-debian11 | ||
|
||
# Set the architecture argument (arm64, i.e. aarch64 as default) | ||
# For amd64, i.e. x86_64, you can append a flag when invoking the build `... --build-arg "ARCH=x86_64"` | ||
ARG ARCH=x86_64 | ||
|
||
# libpq related (required by diesel) | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libpq.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libgssapi_krb5.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libldap_r-2.4.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libkrb5.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libk5crypto.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libkrb5support.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/liblber-2.4.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libsasl2.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libgnutls.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libp11-kit.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libidn2.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libunistring.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libtasn1.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libnettle.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libhogweed.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libgmp.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /usr/lib/${ARCH}-linux-gnu/libffi.so* /usr/lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /lib/${ARCH}-linux-gnu/libcom_err.so* /lib/${ARCH}-linux-gnu/ | ||
COPY --from=build /lib/${ARCH}-linux-gnu/libkeyutils.so* /lib/${ARCH}-linux-gnu/ | ||
|
||
# Application files | ||
COPY --from=build /usr/local/cargo/bin/bookstore /usr/local/bin/bookstore | ||
|
||
CMD ["bookstore"] |
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