-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
42 lines (35 loc) · 902 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Use a Debian-based image for broader library support
FROM rust:1.75-buster AS build
ARG APP_NAME=singularity
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y \
clang \
lld \
musl-tools \
gcc \
libc-dev \
git \
&& rm -rf /var/lib/apt/lists/*
# Build the application
COPY . .
RUN cargo build --release && \
cp ./target/release/$APP_NAME /bin/server
# Use a minimal runtime image
FROM debian:buster-slim AS final
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
libssl-dev \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Create a non-privileged user
ARG UID=10001
RUN useradd -u $UID -m appuser
USER appuser
# Copy the executable and assets
COPY --from=build /bin/server /bin/server
COPY singularity.yaml .
COPY src/ src/
# Expose the port and set the CMD
EXPOSE 8080
CMD ["/bin/server"]