diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..7cba1ef6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM alpine +RUN apk --update add git zola python3 rsync py3-pip curl g++ && \ + ln -s /usr/bin/python3 /usr/bin/python && \ + pip3 install python-slugify rtoml && \ + git clone https://github.com/ppeetteerrs/obsidian-zola && \ + mkdir /obsidian +ENV VAULT=/obsidian +RUN curl -sSf https://sh.rustup.rs | sh -s -- -y && \ + source ~/.cargo/env && \ + cargo install obsidian-export +ENV PATH="$HOME/.cargo/bin:$PATH" +COPY entrypoint.sh / +RUN cp $HOME/.cargo/bin/obsidian-export /obsidian-zola/bin/obsidian-export && \ + sed -i 's|zola --root=build serve|zola --root=build serve --interface 0.0.0.0 --base-url $SITE_URL|' /obsidian-zola/local-run.sh && \ + chmod +x /entrypoint.sh + +EXPOSE 1111 +WORKDIR /obsidian-zola +#ENTRYPOINT ["tail", "-f", "/dev/null"] +ENTRYPOINT [ "/entrypoint.sh" ] +#CMD [] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..4ded9fa1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +version: '2' + +services: + obsidian_server: + build: + context: . + container_name: obsidian + restart: always + environment: + - TZ=Asia/Taipei + - SITE_URL="" + volumes: + - ./obsidian:/obsidian + ports: + - "1111:1111" + command: sh local-run.sh diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 00000000..50366d0b --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/sh +if [ -f /obsidian/netlify.toml ]; then + echo 'good luck' + cd /obsidian-zola + sh local-run.sh + sleep infinity +else + echo "netlify.toml not found in the bind mount to /obsidian" + cd /obsidian + cp /obsidian-zola/netlify.example.toml /obsidian/netlify.toml + echo You should set SITE_URL to your public ip, now SITE_URL is $SITE_URL + sed -i 's|SITE_URL = ""|SITE_URL = "'"$SITE_URL"'"|' /obsidian/netlify.toml + cd /obsidian-zola + sh local-run.sh + sleep infinity +fi