Build Project Image
Containers are a best practice for deployment, and offer several advantages for development. This outlines a typical scenario for building images for API Logic Server projects.
TL;DR - edit/use the pre-built dockerfile to build
and push
your project
devops/docker-image/build-image.dockerfile
is pre-built into your project. Alter it for your organization and project name. It contains instructions for using it via the command line to build
and push
your image.
The diagram above identifies 3 important images you can build, described below.
MyApp: containerize project
This is the image you will deploy for production. It includes Python, API Logic Server, any additional packages your require, and your app (Python and logic). These are defined by a dockerfile
.
API Logic Projects1 include a devops/docker-image/build-image.dockerfile
for containerizing your application, shown at right in the diagram below. Click here to see the key files.
A key aspect of images is that you can extend an existing image: add new software to build another image. See the line:
This builds your projects' image, starting with API Logic Server image, for amd (Intel) platforms.
To build an image for your ApiLogicProject:
- On Docker Hub, create a docker repository under your docker account.
- Create / customize your project as your normally would
- Edit
build-image.sh
: changeyour_account/your_repository
as appropriate- Here is an example
- In terminal (not in VSCode docker - docker CLI is not installed there),
cd < your-project>
-
Run
build-image.sh
:
sh devops/docker-image/build_image.sh . # builds the image locally
- Test the image locally - see Run Container
-
Deploy to Docker Hub
docker tag your_account/your_repository your_account/your_repository:1.00.00
docker login
docker push your_account/your_repository:1.00.00
To run your project container, see the next page.
MyPkgs: Containerize Packages
Your project may require additional packages not already included with API Logic Server. You have 2 choices how to include these:
-
Standard
pip
- per Python standards, your project includes arequirements.txt
file; update it with your dependencies. -
If your team is using Dev Containers for development, it is a best practice to establish dependencies in a new image
MyPkgs
, then build yourMyApp
container from that.
MyDB: Test Databases
One of the great things about Docker is the ability to install popular databases, with no hassle. Follow the procedures described in Connection Examples.\
You can use this to optionally manage your test databases with containers that can run both locally, or on a cloud / server.
-
Several changes were made as of release 9.01.17. ↩