Files
Arno-FastAPI/README.md
2023-09-07 08:20:35 +00:00

1.7 KiB

python-3-8-fastapi

Base Image

Building the base image requires access to docker.sciocatti.com to pull the docker.sciocatti.com/python:3.8-slim image. Pulling this base image also requires access. If you do not have access to this registry, you can

  1. create your own image by replacing docker.sciocatti.com/python:3.8-slim with python:3.8-slim in base_image/Dockerfile.python-3-8-fastapi, and
  2. building the dockerfile and using that as the base.
  3. Optionally, you can push that to your own registry.

If you do have access you can update the base image by

  1. Updating base_image/Dockerfile.python-3-8-fastapi, and
  2. Running the following:
    cd base_image
    # Build
    docker build -f Dockerfile.python-3-8-fastapi -t docker.sciocatti.com/python-3.8-fastapi:{{tag}} .
    # Push
    docker push docker.sciocatti.com/python-3.8-fastapi:{{tag}}
    

Installed libraries

  • FastApi
  • Python-dotenv
  • Requests
  • MySQL / MariaDB connector

Changing this from the template

This is almost ready to go as-is, you just need to make some tweaks:

  1. Change the port in deploy/run.sh. By default the app will be running on port 64000 on your host.
  2. Change the name of the output image in deploy/build.sh and potentially disable the push to the registry.
  3. Change the K3S deployment details in deploy/deployment.yaml. This is made specifically for my cluster, so adapt for yours if using yours.

Running & Building

Running

You only need docker to run this, and access to relevant images.

# In project root
bash run.sh

Building

# In project root
bash build.sh

Deploying

  1. Update dockerfile.
  2. Build the image.
  3. Push the image.
  4. Restart deployment in cluster.