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..df98544 --- /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 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 +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 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/vanikam /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'