From 14ee680583fdef46e47a50dc32c565823a0ebb95 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Wed, 16 Aug 2023 17:22:54 +1000 Subject: [PATCH] main: Added docker for the master server --- .gitea/workflows/build.yml | 29 +++++++++++++++++++++++++++++ README.md | 14 ++++++++++---- master/Dockerfile | 29 +++++++++++++++++++++++++++++ master/main.py | 38 +++++++++++++++++++------------------- 4 files changed, 87 insertions(+), 23 deletions(-) create mode 100644 .gitea/workflows/build.yml create mode 100644 master/Dockerfile diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..bf59720 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,29 @@ +name: Build Docker +run-name: Build Docker Images +on: [push] + +jobs: + Build Master: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install Docker + run : | + apt-get install ca-certificates curl gnupg + install -m 0755 -d /etc/apt/keyrings + curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg + chmod a+r /etc/apt/keyrings/docker.gpg + echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null + apt-get update + apt-get install docker-ce-cli -y + - name: Build Docker image + run : | + cd master + echo "${{ secrets.DOCKERGIT_TOKEN }}" | docker login git.woodburn.au -u nathanwoodburn --password-stdin + tag_num=$(git rev-parse --short HEAD) + docker build -t hnshosting-master:$tag_num . + docker tag hnshosting-master:$tag_num git.woodburn.au/nathanwoodburn/hnshosting-master:$tag_num + docker push git.woodburn.au/nathanwoodburn/hnshosting-master:$tag_num + docker tag hnshosting-master:$tag_num git.woodburn.au/nathanwoodburn/hnshosting-master:latest + docker push git.woodburn.au/nathanwoodburn/hnshosting-master:latest \ No newline at end of file diff --git a/README.md b/README.md index 3309d37..abc22f5 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,20 @@ This is done to make it easier to manage multiple wordpress sites on multiple se ## Master server install -Install prerequisites: +Docker is the easiest way to install the master server. ``` -chmod +x install.sh -./install.sh +docker run -d -p 5000:5000 -e LICENCE-API=your-api-key -e WORKER_KEY=your-api-key --name hnshosting-master git.woodburn.au/nathanwoodburn/hnshosting-master:latest -v ./data:/data ``` +You can also mount a docker volume to /data to store the files instead of mounting a host directory. -This will create the service to run the master server. +Alternatively you can install it manually. +Set your .env file. +``` +cd master +python3 -m pip install -r requirements.txt +python3 main.py +``` ## Worker server install diff --git a/master/Dockerfile b/master/Dockerfile new file mode 100644 index 0000000..c9198bf --- /dev/null +++ b/master/Dockerfile @@ -0,0 +1,29 @@ +FROM --platform=$BUILDPLATFORM python:3.10-alpine AS builder + +WORKDIR /app + +COPY requirements.txt /app +RUN --mount=type=cache,target=/root/.cache/pip \ + pip3 install -r requirements.txt + +COPY . /app + +# Add mount point for data volume +VOLUME /data + +ENTRYPOINT ["python3"] +CMD ["main.py"] + +FROM builder as dev-envs + +# RUN <