🏡 index : ~doyle/bin.git

author Alistair Bahr <alistair.bahr@outlook.com> 2023-10-17 15:20:13.0 +00:00:00
committer jordan <jordan@doyle.la> 2023-10-17 15:56:01.0 +00:00:00
commit
dc6f9b5ec6e125b8a22437443406f8168279dc84 [patch]
tree
4ab48b336e4dfbff3fec7d187150baef6478c5d9
parent
793c2476af0f62885be7b0358b2913e87d346a03
download
dc6f9b5ec6e125b8a22437443406f8168279dc84.tar.gz

use static linking in Dockerfile; add docker-compose.yml



Diff

 Dockerfile         | 12 +++++++-----
 docker-compose.yml |  8 ++++++++
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 5c49b4d..2dc4861 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,15 +1,17 @@
FROM rust:1-slim AS builder

RUN apt update && apt install -y libclang-dev
RUN apt-get update && \
    apt-get install -y libclang-dev musl-tools
RUN rustup target add x86_64-unknown-linux-musl

COPY . /sources
WORKDIR /sources
RUN cargo build --release
RUN chown nobody:nogroup /sources/target/release/bin

# force static linking with target to avoid glibc issues
RUN cargo build --release --target x86_64-unknown-linux-musl
RUN chown nobody:nogroup /sources/target/x86_64-unknown-linux-musl/release/bin

FROM debian:bullseye-slim
COPY --from=builder /sources/target/release/bin /pastebin
COPY --from=builder /sources/target/x86_64-unknown-linux-musl/release/bin /pastebin

USER nobody
EXPOSE 8000
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..70f20ac
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,8 @@
version: '3'
services:
  bin:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8000:8000"
\ No newline at end of file