This repository was archived by the owner on May 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (28 loc) · 1.29 KB
/
Dockerfile
File metadata and controls
48 lines (28 loc) · 1.29 KB
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
46
47
48
# ------------------------------------------------------------------------------
# Cargo Build Stage
# ------------------------------------------------------------------------------
FROM rust:1.52.1 as cargo-build
ARG FEATURES
RUN apt-get update
WORKDIR /usr/src/kalaxia-api
COPY Cargo.toml Cargo.lock /usr/src/kalaxia-api/
RUN mkdir src/
RUN echo "fn main() {println!(\"if you see this, the build broke\")}" > src/main.rs
RUN cargo install sqlx-cli --no-default-features --features postgres
RUN cargo build --release --features="vendored,$FEATURES"
RUN rm -f target/release/deps/kalaxia_api*
COPY src src/
RUN cargo build --release --features="vendored,$FEATURES"
# ------------------------------------------------------------------------------
# Final Stage
# ------------------------------------------------------------------------------
FROM ubuntu:latest
WORKDIR /home/kalaxia/bin/
COPY --from=cargo-build /usr/src/kalaxia-api/target/release/kalaxia-api .
# COPY --from=cargo-build /usr/local/cargo/sqlx /usr/bin/
RUN apt-get update
RUN apt-get install ca-certificates libcap2-bin -y && \
setcap 'cap_net_bind_service=+ep' /home/kalaxia/bin/kalaxia-api && \
addgroup --gid 1000 kalaxia && \
adduser --disabled-login --shell /bin/sh -u 1000 --gid 1000 kalaxia
CMD ["./kalaxia-api"]