-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
45 lines (34 loc) · 1003 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
43
44
45
# Configuration file for the Scrippt API Server Docker container
#
# Scrippt (c) 2023 by Scrippt
#
# Use Rust image
FROM rust:1.69.0 AS builder
# Create app directory
RUN USER=root cargo new --bin server
WORKDIR /server
# Copy your directory over
ADD . ./
# Build for release
RUN cargo build --release
# Use minimal Debian image and set APP variable
FROM debian:bullseye-slim
ARG APP=/usr/src/app
# Install OpenSSL and CA certificates
RUN apt-get update && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/*
# Set environment variables
ENV TZ=Etc/UTC \
APP_USER=appuser
# Create appuser
RUN groupadd $APP_USER && \
useradd -g $APP_USER $APP_USER \
&& mkdir -p ${APP}
# Copy the build artifact from the build stage
COPY --from=builder /server/target/release/server ${APP}/server
COPY --from=builder /server/assets ${APP}
RUN chown -R $APP_USER:$APP_USER ${APP}
# Run the binary as non-root user
USER $APP_USER
WORKDIR ${APP}
# Run the binary
CMD ["./server"]