diff --git a/packs/fetch/build/Dockerfile b/packs/fetch/build/Dockerfile index b616c48..bcba302 100644 --- a/packs/fetch/build/Dockerfile +++ b/packs/fetch/build/Dockerfile @@ -1,7 +1,7 @@ FROM alpine:3.18 RUN apk update RUN apk add git openssh openssh-client -COPY --chmod=0400 ssh_config /etc/ssh/ssh_config +COPY --chmod=0755 ssh_config /etc/ssh/ssh_config COPY --chmod=0755 init.sh /init.sh RUN adduser -D -u 1000 kubero diff --git a/packs/fetch/build/init.sh b/packs/fetch/build/init.sh index 9c03478..5037e9f 100644 --- a/packs/fetch/build/init.sh +++ b/packs/fetch/build/init.sh @@ -5,6 +5,19 @@ #ssh-add /root/.ssh/* #ssh-keyscan github.com >>~/.ssh/known_hosts + +# if not root, copy ssh keys and set permissions +if [ ! "$(id -u)" -eq 0 ]; then + echo "========== copy ssh keys" + mkdir -p ~/.ssh + cp -r ~/.ssh-mounted/* ~/.ssh/ + chmod -v 700 ~/.ssh + chmod -v 600 ~/.ssh/* + #chmod -v 644 ~/.ssh/*.pub + touch ~/.ssh/known_hosts + chmod -v 644 ~/.ssh/known_hosts +fi + echo "========== whipe the app dir" rm -rf /app/* /app/.* >> /dev/null 2>&1 diff --git a/packs/fetch/docker-compose.yaml b/packs/fetch/docker-compose.yaml index 385bc17..547e594 100644 --- a/packs/fetch/docker-compose.yaml +++ b/packs/fetch/docker-compose.yaml @@ -1,8 +1,8 @@ version: "3.3" services: - base-build: - container_name: "base-build" + fetcher: + container_name: "fetcher" build: context: ./build working_dir: /app @@ -13,4 +13,5 @@ services: - GIT_BRANCH=${GIT_BRANCH:-main} volumes: - ../../data:/app - - ../../keys/deploykey:/root/.ssh/deploykey \ No newline at end of file + - ../../keys/deploykey:/root/.ssh/deploykey + - ../../keys/deploykey:/home/kubero/.ssh-mounted/deploykey \ No newline at end of file