Bootstrap FreeKB - PayPal - Checkout using PayPal-Python-Server-SDK on Docker
PayPal - Checkout using PayPal-Python-Server-SDK on Docker

Updated:   |  PayPal articles

This assumes you are already configured the PayPal Python SDK, for example, in VSCode or on a Linux system. If not, check out my article FreeKB - PayPal - Checkout using PayPal-Python-Server-SDK.

First and foremost, let's create a Docker image. Let's say you have a Linux system. Let's create a directory named my_image.

mkdir my_image

 

And move into the directory.

cd my_image

 

Let's create a file named Dockerfile that contains the following.

FROM tiangolo/uwsgi-nginx-flask:python3.11
RUN apt-get update -y

RUN pip install --upgrade pip
COPY ./requirements.txt /usr/requirements.txt
RUN pip install -r /usr/requirements.txt

 

And let's create a file named requirements.txt that contains the following.

flask==2.2.5
paypal-server-sdk==1.1.0

 

Use the docker build command to create an image using the Dockerfile.

docker build --file Dockerfile --tag my-paypal-image:latest .

 

The docker images command can be used to display the images.

docker images

 

Which should return something like this.

REPOSITORY        TAG     IMAGE ID      CREATED             SIZE
my-paypal-image   latest  fb60d5e3e7c8  About a minute ago  5.6MB

 

Let's say you have the files that make up your Flask app in the /usr/local/docker/app directory on your Linux system. 

The docker run command can be used to create a container from the image using the files that make up your Flask app.

sudo docker run
--detach
--restart unless-stopped
--name my-paypal-container
--publish 0.0.0.0:12345:80
--volume /usr/local/docker/app/main.py:/app/main.py
--volume /usr/local/docker/app:/app/my_app
my-paypal-container:latest

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 47de19 in the box below so that we can be sure you are a human.