From cc52131f8a43fec78f53c3e7dfe787fb51a9cac3 Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Thu, 11 Jul 2024 02:47:14 +0530 Subject: [PATCH 1/3] feat: pkg vanikam as container --- .dockerignore | 11 +++++++++++ Dockerfile | 30 ++++++++++++++++++++++++++++++ scripts/entrypoint.sh | 15 +++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 scripts/entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..caebde4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +/target +.env +# Devenv +.devenv* +devenv.local.nix + +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e8f7fd9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +#FROM node:16.9.1 as frontend +#COPY package.json package-lock.json /src/ +#WORKDIR /src +#RUN npm install +#COPY . . +#RUN npm run sass +# +FROM rust:slim as rust +WORKDIR /src +RUN apt-get update && apt-get install -y git pkg-config libssl-dev make +RUN mkdir src && echo "fn main() {}" > src/main.rs +COPY Cargo.toml . +RUN sed -i '/.*build.rs.*/d' Cargo.toml +COPY Cargo.lock . +RUN cargo build --release || true +#COPY --from=frontend /src/static/ /src/static/ +COPY . /src +#RUN cd utils/cache-bust && cargo run +RUN cargo build --release + +FROM debian:latest +RUN apt-get update && apt-get install -y libssl-dev ca-certificates +RUN useradd -ms /bin/bash forgeflux +#RUN mkdir -p /var/www/forgeflux && chown forgeflux /var/www/forgeflux +RUN apt-get update && apt-get install -y ca-certificates +COPY scripts/entrypoint.sh /usr/local/bin/entrypoint.sh +RUN chmod +x /usr/local/bin/entrypoint.sh +COPY --from=rust /src/target/release/forgeflux /usr/local/bin/ + +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh new file mode 100644 index 0000000..e485523 --- /dev/null +++ b/scripts/entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +VANIKAM_USER=vanikam + +export HOME=/home/$VANIKAM_USER +#adduser --disabled-password --shell /bin/bash --home $HOME --uid $USER_ID user +#--uid + +if id "$1" &>/dev/null; then + echo "User $VANIKAM_USER exists" +else + useradd -b /home -m -s /bin/bash $VANIKAM_USER +fi + +su $VANIKAM_USER -c 'vanikam' From 1b276ec4e8be4781b1a3be37c1677379033a5b91 Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Thu, 11 Jul 2024 02:54:39 +0530 Subject: [PATCH 2/3] fix: use nightly img --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e8f7fd9..1a3192c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ #COPY . . #RUN npm run sass # -FROM rust:slim as rust +FROM rustlang/rust:nightly-slim as rust WORKDIR /src RUN apt-get update && apt-get install -y git pkg-config libssl-dev make RUN mkdir src && echo "fn main() {}" > src/main.rs From c06feaf790bb3c1c8fa5011c2943f6ed3f63872a Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Thu, 11 Jul 2024 02:58:50 +0530 Subject: [PATCH 3/3] fix: container: bin name --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1a3192c..df98544 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,11 +20,11 @@ RUN cargo build --release FROM debian:latest RUN apt-get update && apt-get install -y libssl-dev ca-certificates -RUN useradd -ms /bin/bash forgeflux -#RUN mkdir -p /var/www/forgeflux && chown forgeflux /var/www/forgeflux +RUN useradd -ms /bin/bash vanikam +#RUN mkdir -p /var/www/vanikam && chown vanikam /var/www/vanikam RUN apt-get update && apt-get install -y ca-certificates COPY scripts/entrypoint.sh /usr/local/bin/entrypoint.sh RUN chmod +x /usr/local/bin/entrypoint.sh -COPY --from=rust /src/target/release/forgeflux /usr/local/bin/ +COPY --from=rust /src/target/release/vanikam /usr/local/bin/ ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]