mirror of
https://github.com/Ravinou/borgwarehouse
synced 2024-06-26 01:10:03 +02:00
feat: add ssh init
This commit is contained in:
parent
7e21c7b379
commit
f4479bb2f8
|
@ -1,4 +1,4 @@
|
|||
FROM node:18-buster-slim
|
||||
FROM node:18-bookworm-slim
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y curl git jq borgbackup openssh-server && \
|
||||
|
@ -9,6 +9,8 @@ RUN groupadd borgwarehouse
|
|||
|
||||
RUN useradd -m -g borgwarehouse borgwarehouse
|
||||
|
||||
RUN cp /etc/ssh/sshd_config /etc/ssh/moduli /home/borgwarehouse/
|
||||
|
||||
WORKDIR /home/borgwarehouse/app
|
||||
|
||||
COPY . .
|
||||
|
@ -21,7 +23,7 @@ RUN npm ci --only=production
|
|||
|
||||
RUN npm run build
|
||||
|
||||
EXPOSE 3000
|
||||
EXPOSE 3000 22
|
||||
|
||||
ENTRYPOINT ["./docker-bw-init.sh"]
|
||||
|
||||
|
|
|
@ -6,6 +6,14 @@ SSH_DIR="/home/borgwarehouse/.ssh"
|
|||
AUTHORIZED_KEYS_FILE="$SSH_DIR/authorized_keys"
|
||||
REPOS_DIR="/home/borgwarehouse/repos"
|
||||
|
||||
init_ssh_server() {
|
||||
if [ -z "$(ls -A /etc/ssh)" ]; then
|
||||
echo "/etc/ssh is empty, generating SSH host keys..."
|
||||
ssh-keygen -A
|
||||
cp /home/borgwarehouse/sshd_config /home/borgwarehouse/moduli /etc/ssh/
|
||||
fi
|
||||
}
|
||||
|
||||
create_ssh_directory() {
|
||||
if [ ! -d "$SSH_DIR" ]; then
|
||||
echo "The .ssh directory does not exist, creating..."
|
||||
|
@ -29,6 +37,7 @@ create_repos_directory() {
|
|||
fi
|
||||
}
|
||||
|
||||
init_ssh_server
|
||||
create_ssh_directory
|
||||
create_authorized_keys_file
|
||||
create_repos_directory
|
||||
|
|
Loading…
Reference in a new issue