-
Notifications
You must be signed in to change notification settings - Fork 5
The Infrastructure
Infrastructrue and CI/CD pipeline as of Sprint 1
ℹ️ "Progphil Bot" or "Bot" will be referred to ProgPhil Discord Bot itself.
ℹ️ "Server" will refer to "remote server" or "hosted server", not "discord server".
The Current ProgPhil Discord Bot Diagram
Docker is a popular software used in creating and building containerized applications. Why do we need to containerize our application? Docker allows us to package our app with its required libs and dependencies inside the docker container to make our deployment into the server more efficient, taking up less space and time. It will be easier for the ops team to deliver changes in the codebase and dependencies to the serving by rebuilding the image of the new app and restarting the running container deployed in the server.
To run Docker in your local machine you must have installed it. You can use other frontend for Docker Management like Portainer if you want to.
Please refer to these link for download and installation:
The Operations team will be utilizing the docker container in maintaining, stabilizing, and scaling the bot.
The Dockerfile is like a blueprint, where Docker can read instructions on how to build a Docker image. It includes instructions which operating system will be used, what programming language, dependencies, or libraries are need to be installed to run the ProgPhil Bot, and other specific operations on how we will manage our images, containers, and the bot inside it. Dockerignore on other hand functions like gitignore, which excludes files and directories to ignore in the code when building the image.
This is the current Dockerfile: Dockerfile
First, we will use python:3.10-slim, an existing image in the dockerhub where we will build our bot.
FROM python:3.10-slim
ARG are build-time variables, this is useful if you want to pass discord-token as ARG in which will be converted into ENV during build-time. ENV are variables available both during build-time and run-time. Remember, passing discord-token as ARG is completely optional.
ARG token
ENV token=$token
This are the essential ENV configurations for python and poetry to work.
PYTHONUNBUFFERED=1 \
PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VERSION=1.3.2
This part will install poetry using pip and adds it to PATH.
RUN pip install -U pip \
&& apt-get update \
&& pip install "poetry==1.3.2"
ENV PATH="${PATH}:/root/.poetry/bin"
Now, it will install the bot's required dependencies and libraries.
# Install Poetry dependencies
WORKDIR /progphil-bot
COPY poetry.lock pyproject.toml ./
RUN poetry config virtualenvs.create false \
&& poetry install --no-dev
The remaining commands include putting the source code on /progphil-bot directory, and the CMD will run our bot.
The current CI/CD Pipeline