aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-04-19 20:46:01 -0700
committerFuwn <[email protected]>2022-04-19 20:46:01 -0700
commit801411024629f8ab6d6a161f7c4ba3be68556c91 (patch)
tree221bb1103b0abe0820f49853680482ef450b0703
parentfix(route): remove debug logs (diff)
downloadlocus-801411024629f8ab6d6a161f7c4ba3be68556c91.tar.xz
locus-801411024629f8ab6d6a161f7c4ba3be68556c91.zip
ci(docker): fix image
For some unknown reason, -- after adding the new dependencies required for the proper search engine which was implemented in the previous commits -- the Docker image had stoped working. This is me fixing the Docker image.
-rw-r--r--.dockerignore2
-rw-r--r--.gitignore1
-rw-r--r--Dockerfile49
-rw-r--r--Makefile.toml2
4 files changed, 26 insertions, 28 deletions
diff --git a/.dockerignore b/.dockerignore
index a248225..3c0803c 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,11 +1,9 @@
# Rust
target/
-Cargo.lock
# IDE
.idea/
# Development
*.pem
-*.db
.locus/
diff --git a/.gitignore b/.gitignore
index a248225..48f08cc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,5 +7,4 @@ Cargo.lock
# Development
*.pem
-*.db
.locus/
diff --git a/Dockerfile b/Dockerfile
index 66fad04..68c8311 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,41 +1,42 @@
-FROM rust:latest as builder
+FROM clux/muslrust:nightly-2022-04-16 AS environment
-RUN update-ca-certificates
+ENV CHANNEL=nightly-2022-04-16
-# ENV USER=locus
-# ENV UID=10001
+RUN curl "https://static.rust-lang.org/rustup/archive/${RUSTUP_VER}/${RUST_ARCH}/rustup-init" -o rustup-init \
+ && chmod +x rustup-init \
+ && ./rustup-init -y --default-toolchain ${CHANNEL} --profile minimal \
+ && rm rustup-init \
+ && ~/.cargo/bin/rustup target add x86_64-unknown-linux-musl \
+ && echo "[build]\ntarget = \"x86_64-unknown-linux-musl\"" > ~/.cargo/config
-# RUN adduser \
-# --disabled-password \
-# --gecos "" \
-# --home "/nonexistent" \
-# --shell "/sbin/nologin" \
-# --no-create-home \
-# --uid "${UID}" \
-# "${USER}"
+FROM environment as builder
-WORKDIR /locus
+WORKDIR /usr/src
-COPY ./ ./
+RUN cargo new locus
-RUN cargo build --release
+WORKDIR /usr/src/locus
-RUN strip -s /locus/target/release/locus
+COPY Cargo.* .
+
+RUN cargo build --release
-FROM debian:buster-slim
+COPY . .
-RUN apt-get update && apt-get install -y libssl-dev
+RUN --mount=type=cache,target=/usr/src/locus/target \
+ --mount=type=cache,target=/root/.cargo/registry \
+ cargo build --release --bin locus \
+ && strip -s /usr/src/locus/target/x86_64-unknown-linux-musl/release/locus \
+ && mv /usr/src/locus/target/x86_64-unknown-linux-musl/release/locus .
-COPY --from=builder /etc/passwd /etc/passwd
-COPY --from=builder /etc/group /etc/group
+FROM gcr.io/distroless/static:nonroot
WORKDIR /locus
-COPY --from=builder /locus/target/release/locus ./
-COPY --from=builder /locus/content ./content
+COPY --from=builder --chown=nonroot:nonroot /usr/src/locus/locus .
-# USER locus:locus
+COPY --from=builder --chown=nonroot:nonroot /usr/src/locus/content ./content
EXPOSE 1965
-CMD ["./locus"]
+ENTRYPOINT ["/locus/locus"]
diff --git a/Makefile.toml b/Makefile.toml
index 5596640..cdca5d7 100644
--- a/Makefile.toml
+++ b/Makefile.toml
@@ -56,4 +56,4 @@ args = ["run", "--", "{@}"]
[tasks.docker-build]
dependencies = ["checkfc"]
command = "docker"
-args = ["build", "-t", "fuwn/locus", "."]
+args = ["build", "-t", "fuwn/locus:latest", "."]