Merge pull request 'feat: pkg vanikam as container' (#22) from pkg-container into master
Some checks are pending
ci/woodpecker/push/woodpecker Pipeline is pending

Reviewed-on: #22
This commit is contained in:
Aravinth Manivannan 2024-07-11 03:07:58 +05:30
commit 464e0499f4
3 changed files with 56 additions and 0 deletions

11
.dockerignore Normal file
View file

@ -0,0 +1,11 @@
/target
.env
# Devenv
.devenv*
devenv.local.nix
# direnv
.direnv
# pre-commit
.pre-commit-config.yaml

30
Dockerfile Normal file
View file

@ -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"]

15
scripts/entrypoint.sh Normal file
View file

@ -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'