Skip to content

Commit

Permalink
use static linking in Dockerfile; add docker-compose.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Alistair1231 authored and w4 committed Oct 17, 2023
1 parent 793c247 commit dc6f9b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3'
services:
bin:
build:
context: .
dockerfile: Dockerfile
ports:
- "8000:8000"

0 comments on commit dc6f9b5

Please sign in to comment.