-
Notifications
You must be signed in to change notification settings - Fork 1
3 building
sh3b0 edited this page Oct 13, 2022
·
3 revisions
-
3.1. General
3.2. Python App
3.3. NodeJS App
- Produce artifacts (e.g., executable, application image, software package, zipped source code, etc.) and version them.
- In this context, artifact is the docker image of the web application created from the corresponding
Dockerfile
for both apps.
-
Write a
Dockerfile
in the root directory for each project -
Add build and release instructions to the README.
- Use a Dockerfile linter (e.g., hadolint) as it helps build best practice Docker images.
- Use a small base image that does the job (e.g., alpine-based images) as it will make deployment faster while not taking much space.
-
Copy only the necessary files to the image to make it smaller and faster, use
.dockerignore
to ignore unnecessary files and directories. -
Use
EXPOSE
documentation to make port-forwarding easier for other programmers reading yourDockerfile
. - Push the image to a container registry like DockerHub or the cloud-dedicated container registry for version control of app images and convenient deployment to the cloud.
- Tag the images with it’s version or the corresponding commit id from git to easily understand which version of the code is currently in the registry.
- Set environment variable
PYTHONUNBUFFERED
to a non-zero value to see container output from host in real-time. - Use
--no-cache-dir
flag withpip install
to prevent caching downloaded packages and make image size smaller.
- Set environment variable
NODE_ENV
toproduction
to configure ExpressJS with production settings. - Use
npm ci
instead ofnpm install
(see why).