Utility to simplify Dockerfiles
Project description
Model W Docker
A tool so that your Dockerfile looks like this:
FROM modelw/base:2023.01
COPY --chown=user package.json package-lock.json ./
RUN modelw-docker install
COPY --chown=user . .
RUN modelw-docker build
CMD ["modelw-docker", "serve"]
Organization
This repository contains different elements that work together, found in sub-directories here:
src
— Contains the source of themodelw-docker
package, that is published on Pypi.image
— Is the source for the Docker image that can be used as a base for all Model W projects.demo
— A demo project used to test the image during development
modelw-docker
This is a helper that is pre-installed in the Docker image and helps you build and run a Model W project.
If called from the root of a project, it will automatically detect the project's
type and run appropriate commands for each step of the build. If later on the
way the Docker image is built or the requirements of Model W change, it is
expected that those changes can be reflected in the modelw-docker
package
without requiring the developers to change their Dockerfiles.
Available actions
modelw-docker install
— Installs the project's dependencies (creates the virtualenv, runsnpm install
or whatever is required). It only requires the dependencies files to run (package.json
/package-lock.json
for front components,pyproject.toml
/poetry.lock
for api components).modelw-docker build
— Builds the project. It requires the project to be installed first. It also requires all the source code to be present.modelw-docker serve
— Runs the project. It requires the project to be installed and built first.modelw-docker run
— Runs a command in the project's virtualenv. It requires the project to be installed first.
The reason why install
and build
are separate and why you need first to copy
just the dependencies list and then the source code is to allow for caching of
the dependencies. This way, the dependencies are only re-installed when the
dependencies list changes, not when the source code changes. This makes very
fast builds when only the source code changes.
Dry run
There is a --dry-run
option for all the commands that will just print what
would have been done but not do it. The dry run mode is automatically enabled if
you run the package outside of Docker in order to avoid fucking up your desktop.
Config file
All the settings are automatically detected, however if something isn't to your
taste you can always override it using a model-w.toml
file, following this
structure:
[project]
# For printing purposes
name = "demo_project"
# Either "front" or "api"
component = "api"
[project.required_files]
# All the files to be created before the install step and their content
"src/demo_project/__init__.py" = ""
[apt.repos]
# APT repositories to be added, you need to give both the source and the key
# for each one of them
pgdg.source = "deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main"
pgdg.key = { url = "https://www.postgresql.org/media/keys/ACCC4CF8.asc" }
[apt.packages]
# APT packages to be installed. Put * to install the default version, or a
# version number to install a specific version.
gdal-bin = "*"
In addition, Python project also have the following settings:
[project]
# [...]
# Either "gunicorn" or "daphne"
server = "daphne"
# Modules that have the WSGI and ASGI entry points
wsgi = "demo_project.django.wsgi:application"
asgi = "demo_project.django.asgi:application"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file modelw_docker-2022.10.0a4.tar.gz
.
File metadata
- Download URL: modelw_docker-2022.10.0a4.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.10.8 Linux/5.15.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a1791867722c9057bec9118687e0d34d843e76f19b6a9469d171c21ec135972 |
|
MD5 | 82b267a744f808184834f74d7beb368e |
|
BLAKE2b-256 | 0a364e9fffabac0d01aa124b3ca190486b017e0913ae86e5f828d0f1eee393d7 |
Provenance
File details
Details for the file modelw_docker-2022.10.0a4-py3-none-any.whl
.
File metadata
- Download URL: modelw_docker-2022.10.0a4-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.10.8 Linux/5.15.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b9caad2033d5b05adbae4b955bb135852a25bd8856a1eb329b124dca1273209 |
|
MD5 | 7d1abb20ce1bc6aad75292203bc80c73 |
|
BLAKE2b-256 | 10c6bc9a3470aec1971251b934146a815fa18bbef360d6a9da5e932648333bff |