727d912b3b
`sqlx` requires linking against OpenSSL twice: - `sqlx-macros` needs to link against OpenSSL as a shared libary for use at compile time. - `sqlx` needs to link against OpenSSL a static library for use at runtime. You can find the details here: https://github.com/launchbadge/sqlx/issues/670 https://github.com/sfackler/rust-openssl/issues/1337 We go with the fix proposed by @sfackler, and add a test program that we can use to verify everything works correctly. We remove a few `OPENSSL`-related variables that were added 4 years ago, and that no longer appear to be needed.
26 lines
784 B
Docker
26 lines
784 B
Docker
# -*- mode: dockerfile -*-
|
|
#
|
|
# An example Dockerfile showing how to build a Rust executable using this
|
|
# image, and deploy it with a tiny Alpine Linux container.
|
|
|
|
# You can override this `--build-arg BASE_IMAGE=...` to use different
|
|
# version of Rust or OpenSSL.
|
|
ARG BASE_IMAGE=ekidd/rust-musl-builder:latest
|
|
|
|
# Our first FROM statement declares the build environment.
|
|
FROM ${BASE_IMAGE} AS builder
|
|
|
|
# Add our source code.
|
|
ADD --chown=rust:rust . ./
|
|
|
|
# Build our application.
|
|
RUN cargo build --release
|
|
|
|
# Now, we need to build our _real_ Docker container, copying in `using-sqlx`.
|
|
FROM alpine:latest
|
|
RUN apk --no-cache add ca-certificates
|
|
COPY --from=builder \
|
|
/home/rust/src/target/x86_64-unknown-linux-musl/release/using-sqlx \
|
|
/usr/local/bin/
|
|
CMD /usr/local/bin/using-sqlx
|