summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2021-03-24 22:02:37 +0100
committerSanto Cariotti <santo@dcariotti.me>2021-03-24 22:02:37 +0100
commit9a4d8ef4fd1a9040a2329b8c51a6944c5a131628 (patch)
tree58f9f0fd15889417278ceaf181353d131611ef08
parentf1ff95bb3d84f6bcc4ce20682831609a3446e7b9 (diff)
docker: add dockerfile
-rw-r--r--Dockerfile29
1 files changed, 29 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..7ae6bd5
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,29 @@
+# build stage
+FROM rust:latest as cargo-build
+
+RUN apt-get update && apt-get install musl-tools -y
+RUN rustup target add x86_64-unknown-linux-musl
+
+WORKDIR /usr/src/app
+COPY . .
+
+RUN RUSTFLAGS=-Clinker=musl-gcc cargo build --release
+--target=x86_64-unknown-linux-musl
+
+###################
+# final stage
+FROM alpine:latest
+
+RUN addgroup -g 1000 app
+RUN adduser -D -s /bin/sh -u 1000 -G app app
+
+WORKDIR /home/app/bin/
+COPY --from=cargo-build
+/usr/src/app/target/x86_64-unknown-linux-musl/release/gico-api .
+
+RUN chown app:app gico-api
+USER app
+
+EXPOSE 9090
+
+CMD ["./gico-api"]