docker testing

This commit is contained in:
Ravinou 2023-09-10 17:52:45 +02:00
parent ddc5229136
commit 100c62f39b
No known key found for this signature in database
GPG key ID: EEEE670C40F6A4D7
3 changed files with 59 additions and 0 deletions

7
.dockerignore Normal file
View file

@ -0,0 +1,7 @@
node_modules
.git
.gitignore
.pre-commit-config.yaml
.prettierrc.json
.env.local
.next

28
Dockerfile Normal file
View file

@ -0,0 +1,28 @@
FROM node:18-buster-slim
RUN apt-get update && \
apt-get install -y curl git jq borgbackup openssh-server && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN groupadd borgwarehouse
RUN useradd -m -g borgwarehouse borgwarehouse
WORKDIR /home/borgwarehouse/app
RUN git clone -b v2.0 https://github.com/Ravinou/borgwarehouse.git .
RUN chown -R borgwarehouse:borgwarehouse * .*
USER borgwarehouse
RUN npm ci --only=production
RUN npm run build
EXPOSE 3000
ENTRYPOINT ["./docker-bw-init.sh"]
CMD ["npm", "run", "start"]

24
docker-bw-init.sh Executable file
View file

@ -0,0 +1,24 @@
#!/bin/bash
SSH_DIR="/home/borgwarehouse/.ssh"
AUTHORIZED_KEYS_FILE="$SSH_DIR/authorized_keys"
REPOS_DIR="/home/borgwarehouse/repos"
if [ ! -d "$SSH_DIR" ]; then
echo "The .ssh directory does not exist, creating..."
mkdir -p "$SSH_DIR"
chmod 700 "$SSH_DIR"
fi
if [ ! -f "$AUTHORIZED_KEYS_FILE" ]; then
echo "The authorized_keys file does not exist, creating..."
touch "$AUTHORIZED_KEYS_FILE"
chmod 600 "$AUTHORIZED_KEYS_FILE"
fi
if [ ! -d "$REPOS_DIR" ]; then
echo "The repos directory does not exist, creating..."
mkdir -p "$REPOS_DIR"
fi
exec "$@"