FourDigits CLI tool
Project description
FourDigits CLI
A command line tool to make development and deployment easier within Four Digits.
It has the following commands:
- "docker"
- "build": Build docker images in our Gitlab CI pipelines
- "tag": Create new Docker tag for existing Docker tag on registry
- "gitlab"
- "fix-coverage-paths": Change the generated coverage.xml so Gitlab can show coverage visualization in merge requests
- "exonet"
- "deploy": Deploy a project to Exonet
- "db:download": Download a database from Exonet and import it locally
- "db:copy": Copy a database from one environment to another
- "docker-compose"
- "sync": Sync files from a service to local folder
- "sync:env": Shortcut for django:home/userapp/env -> env-docker
Install
With pipx:
pipx install fourdigits-cli
With pip:
sudo pip install --break-system-packages fourdigits-cli
Upgrade
With pipx:
pipx upgrade fourdigits-cli
With pip:
sudo pip install --upgrade fourdigits-cli
Enable auto complete
bash
Add this to ~/.bashrc
:
eval "$(_4D_COMPLETE=bash_source 4d)"
eval "$(_FOURDIGITS_COMPLETE=bash_source fourdigits)"
Zsh
Add this to ~/.zshrc
:
eval "$(_4D_COMPLETE=zsh_source 4d)"
eval "$(_FOURDIGITS_COMPLETE=zsh_source fourdigits)"
Usage
After installation the cli tool is available under fourdigits
and 4d
.
For more information use:
fourdigits --help
Example: Build a docker image and deploy it to the test environment
Build an image for the tst
environment and upload it to our registry:
$ fourdigits docker build tst --push
Docker build image <docker_tag>
- file=Dockerfile
- context=.
- target=None
Docker create tag <tmp_tag> -> docker-registry.fourdigits.nl/fourdigits/<project>:tst
Docker push tag docker-registry.fourdigits.nl/fourdigits/<project>:tst
Docker create tag <tmp_tag> -> docker-registry.fourdigits.nl/fourdigits/<project>:<docker_tag>
Docker push tag docker-registry.fourdigits.nl/fourdigits/wijsproductportals:<docker_tag>
To deploy this to the tst
environment, use the docker_tag
(not the tmp_tag
) from the previous step:
$ fourdigits exonet deploy tst <docker_tag>
{"id":...,"number":<number>,...}
You can see the progress of the deployment pipeline on https://drone.exonet.nl/exonet/containers-fourdigits/.
Troubleshooting
unauthorized
If you get:
unauthorized: unauthorized to access repository: fourdigits/<project>, action: push: unauthorized to access repository: fourdigits/<project>, action: push
You need to login to the registry:
docker login
docker login docker-registry.fourdigits.nl
Project configuration
The project is configured in the pyproject.toml
file, available options and their defaults:
[project]
name = "default-project"
[tool.fourdigits]
exonet_project_name="<default is project name>"
docker_repo="<default is project name>"
slack_channel="<default is project name>"
docker_image_user="fourdigits"
[tool.fourdigits.envs.<environment anem>]
exonet_environment="<default is environment name>"
# Every setting can be overridden per environment
slack_channel="custom-channel"
Example project with separate nextjs
[project]
name = "django-project"
[tool.fourdigits]
# default to project name
[tool.fourdigits.envs.tst]
[tool.fourdigits.envs.acc]
[tool.fourdigits.envs.prd]
[tool.fourdigits.envs.nextjs_tst]
exonet_project_name = "nextjs"
exonet_environment = "tst"
docker_repo = "nextjs"
[tool.fourdigits.envs.nextjs_acc]
exonet_project_name = "nextjs"
exonet_environment = "acc"
docker_repo = "nextjs"
[tool.fourdigits.envs.nextjs_prd]
exonet_project_name = "nextjs"
exonet_environment = "prd"
docker_repo = "nextjs"
Development
make develop
Releasing
To make a new release available on pypi, follow these steps:
- Update version by edit
fourdigits_cli/__init__.py
and commit. - Run:
make push-version
- Update the installation of fourdigits-cli in https://gitlab.com/fourdigits/utils/docker-pipeline-image/-/blob/main/Dockerfile to the newest version.
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 fourdigits_cli-1.17.0.tar.gz
.
File metadata
- Download URL: fourdigits_cli-1.17.0.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55f33d372f17215c789b0742ca307887424f1049e99682181248cfbadd5cb888 |
|
MD5 | b180f854cc3d6cb5c852ed5d2f997ec9 |
|
BLAKE2b-256 | 552f06981c932a134249bfb5b3d27ed7e5b88bb4d25ad140a7e7c17b42e4a5fc |
File details
Details for the file fourdigits_cli-1.17.0-py3-none-any.whl
.
File metadata
- Download URL: fourdigits_cli-1.17.0-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5f0fee14bfd105e5523e1a8f79bdb390e655d4708864117108fcb921cdaabb7 |
|
MD5 | ab910a2f6849b787a0c6881447e7b1b9 |
|
BLAKE2b-256 | dd4a5c96b982bf8f425896373a8d84356010872310d7f3f0fb98e5b4930fa21b |