Skip to main content

Shinetech Docker CLI.

Project description

Shinetech Docker CLI

PyPI version

Shinetech Docker CLI is a more intelligent, user-friendly and advanced configurable local development environment built with Docker.

Getting Started

sudo pip3 install stdocker

If you get error ERROR: Could not find a version that satisfies the requirement, please use the following command to install:

python3 -m pip install stdocker==1.2.8

It based on the internal docker project Shinetech Docker, please install it first. If you do not have permission to use Shinetech Docker, please ignore this package.

After the installation is successful, you can run the stdocker command in any directory and perform the operations you need.

Use Cases

Run the following command to view the command help.

stdocker

or

stdocker --help

You can see the following information:

Usage: stdocker [OPTIONS] COMMAND [ARGS]...

  Shinetech Docker CLI

Options:
  -d, --working-dir PATH  Location of the installation directory, defaults to
                          /opt/shinetech/stdocker.
  --version               Show the version and exit.
  --help                  Show this message and exit.

Commands:
  about                   Show the local environment and workspace...
  bash                    Bash session for running container
  build                   Build local development environment with your...
  configure               Configure local environment, will guide you...
  create-js-project       Create a new Javascript project based on a base...
  create-magento-project  Create a new Magento project based on the...
  create-php-project      Create a new PHP project based on a base...
  database-export         Export database to SQL file
  database-import         Import database from SQL file
  docker-compose          Execute sudo docker-compose * command
  docker-exec             Execute sudo docker exec * command
  docker-run              Execute sudo docker * command
  editor                  Edit or show configuration of docker-compose.yml
  envs                    List all environments
  logs                    Show or live tail docker container logs
  restart                 Restarts all stopped and running services, or...
  setup-docker-compose    Install or upgrade docker compose
  setup-project           Build a existing project based on existing code...
  start                   Launch docker services
  status                  List all running containers
  stop                    Stop docker services
  switch-network          Switch network mode for a container
  upgrade                 Upgrade Shinetech Docker
  workspace               Initial workspace

For the detailed usage of each command, you can use the following command to view:

stdocker [COMMAND] --help

e.g:

stdocker create-project --help

Run docker command

If you want to run sudo docker * command, you can use our command like this:

stdocker docker-run <DOCKER_COMMAND>

You can check sudo docker and see which original command we supported. Please use double quotes if DOCKER_COMMAND contains spaces or other parameters.

e.g:

stdocker docker-run info

This command is equivalent to:

sudo docker info

Run docker-compose command

If you want to run sudo docker-compose * command, you can use our command like this:

stdocker docker-compose <DOCKER_COMPOSE_COMMAND>

You can check sudo docker-compose and see which original command we supported. Please use double quotes if DOCKER_COMPOSE_COMMAND contains spaces or other parameters.

e.g:

stdocker docker-compose ps

This command is equivalent to:

sudo docker-compose ps

You will see the following result:

NAME                    IMAGE                                                       COMMAND                                                          SERVICE         CREATED          STATUS          PORTS
stdev-elasticsearch-1   stdev-elasticsearch                                         "/bin/tini -- /usr/local/bin/docker-entrypoint.sh eswrapper"     elasticsearch   20 minutes ago   Up 20 minutes   0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 9300/tcp
stdev-elasticvue-1      cars10/elasticvue:0.42.1                                    "nginx -g 'daemon off;'"                                         elasticvue      20 minutes ago   Up 20 minutes   80/tcp, 0.0.0.0:8082->8080/tcp, :::8082->8080/tcp
stdev-golang-1          golang:1.20                                                 "tail -F anything"                                               golang          20 minutes ago   Up 20 minutes   
stdev-mailcatcher-1     stdev-mailcatcher                                           "mailcatcher --smtp-ip=0.0.0.0 --http-ip=0.0.0.0 --foreground"   mailcatcher     20 minutes ago   Up 20 minutes   1025/tcp, 0.0.0.0:1080->1080/tcp, :::1080->1080/tcp
stdev-memcached-1       memcached                                                   "docker-entrypoint.sh memcached"                                 memcached       20 minutes ago   Up 20 minutes   0.0.0.0:11211->11211/tcp, :::11211->11211/tcp
stdev-mongo-1           registry.cn-beijing.aliyuncs.com/shinetech/mongo:5.0.5      "docker-entrypoint.sh mongod"                                    mongo           20 minutes ago   Up 20 minutes   27017/tcp
stdev-mongoexpress-1    mongo-express                                               "tini -- /docker-entrypoint.sh mongo-express"                    mongoexpress    20 minutes ago   Up 20 minutes   0.0.0.0:8081->8081/tcp, :::8081->8081/tcp
stdev-mysql-1           stdev-mysql                                                 "docker-entrypoint.sh mysqld"                                    mysql           20 minutes ago   Up 20 minutes   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp
stdev-nginx-1           stdev-nginx                                                 "/docker-entrypoint.sh /usr/bin/supervisord"                     nginx           20 minutes ago   Up 20 minutes   0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:6081->6081/tcp, :::6081->6081/tcp
stdev-pgweb-1           sosedoff/pgweb                                              "/usr/bin/pgweb --bind=0.0.0.0 --listen=8081"                    pgweb           20 minutes ago   Up 20 minutes   0.0.0.0:8083->8081/tcp, :::8083->8081/tcp
stdev-phpfpm-1          stdev-phpfpm                                                "/docker-entrypoint.sh php-fpm"                                  phpfpm          20 minutes ago   Up 20 minutes   9000/tcp
stdev-phpmyadmin-1      phpmyadmin:latest                                           "/docker-entrypoint.sh apache2-foreground"                       phpmyadmin      20 minutes ago   Up 20 minutes   0.0.0.0:8080->80/tcp, :::8080->80/tcp, 0.0.0.0:8443->443/tcp, :::8443->443/tcp
stdev-phpredisadmin-1   erikdubbelboer/phpredisadmin:latest                         "tini -- php -S 0.0.0.0:80"                                      phpredisadmin   20 minutes ago   Up 20 minutes   0.0.0.0:8089->80/tcp, :::8089->80/tcp
stdev-postgres-1        postgres                                                    "docker-entrypoint.sh postgres"                                  postgres        20 minutes ago   Up 20 minutes   5432/tcp
stdev-python-1          python:3.9                                                  "tail -F anything"                                               python          20 minutes ago   Up 20 minutes   
stdev-rabbitmq-1        rabbitmq:3.9-management                                     "docker-entrypoint.sh rabbitmq-server"                           rabbitmq        20 minutes ago   Up 20 minutes   4369/tcp, 5671-5672/tcp, 15671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp
stdev-redis-1           redis:6.2.6                                                 "docker-entrypoint.sh redis-server --appendonly no"              redis           20 minutes ago   Up 20 minutes   0.0.0.0:6379->6379/tcp, :::6379->6379/tcp
stdev-webgrind-1        registry.cn-beijing.aliyuncs.com/shinetech/webgrind:1.9.2   "docker-php-entrypoint apache2-foreground"                       webgrind        20 minutes ago   Up 20 minutes   0.0.0.0:8084->80/tcp, :::8084->80/tcp

NOTE: You can also use stdocker status list all running docker containers.

Run docker exec command

If you want to run sudo docker exec * command, you can use our command like this:

stdocker docker-exec <COMMAND>

You can check sudo docker exec --help and see which original command we supported. Please use double quotes if COMMAND contains spaces or other parameters.

e.g:

stdocker docker-exec "-it stdev-phpfpm-1 /bin/bash"

This command is equivalent to:

sudo docker exec -it stdev-phpfpm-1 /bin/bash

Log in to the specified server using SSH

stdocker bash <SERVICE>

e.g:

stdocker bash phpfpm
stdocker bash mysql

Or, Bash commands are compatible with container name and service:

stdocker bash stdev-phpfpm-1
stdocker bash stdev-mysql-1

This command is equivalent to:

sudo docker exec -it stdev-phpfpm-1 /bin/bash
sudo docker exec -it stdev-mysql-1 /bin/bash

Launch docker services

It will stop local services and launch the docker services

stdocker start

Stop docker services

It will stop the docker services and launch local services

stdocker stop

Restart specified docker service

stdocker restart <SERVICE>

e.g:

stdocker restart # Restart all services
stdocker restart nginx
stdocker restart phpfpm

Configure local environment

It will guide you through creating your .env and docker-compose.yml

stdocker configure

Build local development environment with your configuration

Switch and build your development environment using the following command:

stdocker build <ENV>

If ENV is empty, it will guide you to create your customized configuration, otherwise will base on your specified env to build services.

stdocker build
stdocker build --env=magento_246

Export and import database

Export database:

Default to export MySQL database:

stdocker database-export --database-name=test

If you want to export other database, you can specify the database type and version:

stdocker database-export --database-name=test --database-type=mariadb --database-version=10.5

Import database:

Default to export MySQL database:

stdocker database-import --database-name=test --backup-sql-file=test_20220823.sql

If you want to import other database, you can specify the database type and version:

stdocker database-import --database-name=test --backup-sql-file=test_20220823.sql --database-type=mariadb --database-version=10.5

Show the local environment and workspace information

stdocker about

You can see the following information:

Current environment:
 - lamp
Your workspace information:
 - Workspace: /home/sunfeng/stdocker
 - Project Directory: /home/sunfeng/stdocker/app
 - Nginx VHosts: /home/sunfeng/stdocker/config/services/nginx/sites-enabled
 - Nginx Log: /home/sunfeng/stdocker/var/logs/nginx
 - Apache VHosts: /home/sunfeng/stdocker/config/services/apache/sites-enabled
 - Apache Log: /home/sunfeng/stdocker/var/logs/apache2
 - SSL CA: /home/sunfeng/stdocker/config/services/ca
 - php.ini: /home/sunfeng/stdocker/config/services/php/php.ini
 - Composer auth.json: /home/sunfeng/stdocker/config/services/composer/auth.json
 - MySQL Log: /home/sunfeng/stdocker/var/logs/mysql

List all environments

stdocker envs

You can see the following information:

+---------------+-------------+------------+-----+-------+---------+------------+---------------+------------+-------+---------------+----------+-------------+---------+---------------+------------+-------+
|               |  Env Code   | Web Server | PHP | MySQL | MariaDB | phpMyAdmin | Elasticsearch | Elasticvue | Redis | phpRedisAdmin | RabbitMQ | Mailcatcher | MongoDB | Mongo Express | PostgreSQL | Pgweb |
+---------------+-------------+------------+-----+-------+---------+------------+---------------+------------+-------+---------------+----------+-------------+---------+---------------+------------+-------+
|  Basic LNMP   |    basic    |   nginx    | 7.4 |  8.0  |    N    |     Y      |       N       |     N      |   N   |       N       |    N     |      N      |    N    |       N       |     N      |   N   |
+---------------+-------------+------------+-----+-------+---------+------------+---------------+------------+-------+---------------+----------+-------------+---------+---------------+------------+-------+
|   Full LNMP   |    full     |   nginx    | 7.4 |  8.0  |    N    |     Y      |     7.16      |     Y      |  6.2  |       Y       |   3.9    |      Y      |    Y    |       Y       |     Y      |   Y   |
+---------------+-------------+------------+-----+-------+---------+------------+---------------+------------+-------+---------------+----------+-------------+---------+---------------+------------+-------+
|     LAMP      |    lamp     |   apache   | 7.4 |  8.0  |    N    |     Y      |     7.16      |     N      |  6.2  |       N       |   3.9    |      Y      |    N    |       N       |     N      |   N   |
+---------------+-------------+------------+-----+-------+---------+------------+---------------+------------+-------+---------------+----------+-------------+---------+---------------+------------+-------+
|     LNMP      |    lnmp     |   nginx    | 7.4 |  8.0  |    N    |     Y      |     7.16      |     N      |  6.2  |       N       |   3.9    |      Y      |    N    |       N       |     N      |   N   |
+---------------+-------------+------------+-----+-------+---------+------------+---------------+------------+-------+---------------+----------+-------------+---------+---------------+------------+-------+
|  Magento 2.3  | magento_23  |   nginx    | 7.3 |  5.7  |    N    |     Y      |      7.6      |     Y      |  5.0  |       Y       |   3.8    |      Y      |    N    |       N       |     N      |   N   |
+---------------+-------------+------------+-----+-------+---------+------------+---------------+------------+-------+---------------+----------+-------------+---------+---------------+------------+-------+
|  Magento 2.4  | magento_24  |   nginx    | 7.4 |  8.0  |    N    |     Y      |     7.16      |     Y      |  6.2  |       Y       |   3.8    |      Y      |    N    |       N       |     N      |   N   |
+---------------+-------------+------------+-----+-------+---------+------------+---------------+------------+-------+---------------+----------+-------------+---------+---------------+------------+-------+
| Magento 2.4.4 | magento_244 |   nginx    | 7.4 |  8.0  |    N    |     Y      |     7.16      |     Y      |  6.2  |       Y       |   3.9    |      Y      |    N    |       N       |     N      |   N   |
+---------------+-------------+------------+-----+-------+---------+------------+---------------+------------+-------+---------------+----------+-------------+---------+---------------+------------+-------+
| Magento 2.4.5 | magento_245 |   nginx    | 8.1 |  8.0  |    N    |     Y      |     7.17      |     Y      |  6.2  |       Y       |   3.9    |      Y      |    N    |       N       |     N      |   N   |
+---------------+-------------+------------+-----+-------+---------+------------+---------------+------------+-------+---------------+----------+-------------+---------+---------------+------------+-------+

The highlight row is your current environment, you can use Env Code for stdocker build --env=<ENV> command.

Initial workspace

It will initial your workspace to your home or specified directory, and update env config.

stdocker workspace

Create and setup project

Create a new PHP project based on a base template or framework skeleton

stdocker create-php-project [OPTIONS]

Create a Magento 2 project:

stdocker create-php-project --platform=magento --project-name=m2project --target-version=2.4.5

e.g:

Create a Symfony project:

stdocker create-php-project --platform=symfony --project-name=sfproject

Create a new Magento project based on the source code or composer

Please download the Magento source code from the official website first if use source code to create project.

stdocker create-magento-project [OPTIONS]

e.g:

Create a Magento 2.4.5 project with source code:

stdocker create-magento-project --version-number=2.4.5 --source-code-file=/home/sunfeng/Downloads/adobe-commerce-2.4.5-2022-07-21-08-24-23.zip

Create a Magento 2.4.5 project with custom project name:

stdocker create-magento-project --version-number=2.4.5 --source-code-file=/home/sunfeng/Downloads/adobe-commerce-2.4.5-2022-07-21-08-24-23.zip --project-name=testproject

Create a Magento 2.4.5 project with composer:

stdocker create-magento-project --version-number=2.4.5

Also, we can specify Adobe Commerce and Magento Open Source via --version:

  • enterprise: Adobe Commerce
  • community: Magento Open Source

Create a Magento 2.4.5 project using Adobe Commerce with composer:

stdocker create-magento-project --version=enterprise --version-number=2.4.5

Create a Magento 2.4.5 project using Magento Open Source with composer:

stdocker create-magento-project --version=community --version-number=2.4.5

Create a new Javascript project based on a base template or framework skeleton

stdocker create-js-project [OPTIONS]

e.g:

Create a React project:

stdocker create-js-project --platform=react --project-name=reactproject

Build an existing project based on existing code and database

stdocker setup-project [OPTIONS]

Setup HP project:

stdocker setup-project --project-name=hp --db-sql-file=/home/sunfeng/Downloads/20220824201501.sql --country=id

Upgrade Shinetech Docker

stdocker upgrade

Upgrade to the specified version:

stdocker upgrade --target_version=1.0.1

If you want to restart docker services after upgrade, please use the following command:

stdocker upgrade --force

Switch network mode for a container

stdocker switch-network [OPTIONS] SERVICE
stdocker switch-network phpfpm --network-mode=host
stdocker switch-network phpfpm --network-mode=bridge

Edit or show configuration of docker-compose.yml

stdocker editor [OPTIONS]

Show the configuration in terminal:

stdocker editor

Edit the configuration via vim:

stdocker editor --edit-mode

Show or live tail docker container logs

stdocker logs [OPTIONS] SERVICE

Show all logs for specified container

stdocker logs phpfpm

Tail logs for specified container

stdocker logs phpfpm --follow

Install or upgrade docker compose

stdocker setup-docker-compose [OPTIONS] [VERSION]

Install or upgrade to default version:

stdocker setup-docker-compose

Install or upgrade to default version:

stdocker setup-docker-compose 1.29.2
stdocker setup-docker-compose v2.19.1

NOTE: Find the newest version from https://github.com/docker/compose/releases

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[1.2.8] - 2024-01-11

Added

  • Add Stirling PDF, Dynamodb and Dynamodb Admin to env list
  • Add WooCommerce to PHP platforms

[1.2.7] - 2024-01-05

Fixed

  • Fix restart container bugs
  • Fix HTTPError: 400 Bad Request error for twine upload

[1.2.6] - 2023-12-25

Added

  • Add ThinkPHP to PHP platforms
  • Add SonarQube to env list

[1.2.5] - 2023-11-17

Added

  • Set dynamic max width according to columns of terminal size for env list

[1.2.4] - 2023-11-16

Added

  • Add MSSQL to env list

[1.2.3] - 2023-11-15

Fixed

  • Fix database export bug
  • Fix local install package bug
  • Fix selected multiple version display issue for env list

[1.2.2] - 2023-11-14

Added

  • Split database import and export to independent commands
  • Change default env build to Magento 2.4.6
  • Convert multiple service version list to string for env list

Fixed

  • Fix database version issue for create Magento project

[1.2.1] - 2023-11-13

Fixed

  • Fix database version issues

[1.2.0] - 2023-11-13

Fixed

  • Fix package issues for publish and debug

[1.1.9] - 2023-11-13

Added

  • Add database type and version for database import and export
  • Add database type and version for create Magento project

[1.1.8] - 2023-10-31

Added

  • Add OpenSearch to env list

[1.1.7] - 2023-10-27

Added

  • Add C++ and Rust to env list
  • Add bash commands are compatible with container name and service name

[1.1.6] - 2023-10-26

Added

  • Add .Net Core, Java and Ruby to env list

[1.1.5] - 2023-10-23

Added

  • Add Node to env list

[1.1.4] - 2023-10-10

Added

  • Upgrade docker compose to v2
  • Fix docker container name with -, and _ only support for docker compose v1

[1.1.3] - 2023-10-09

Added

  • Add Python and Golang to env list

Fixed

[1.1.2] - 2023-09-06

Added

  • Add Magento version selection for setup Magento project command

[1.1.1] - 2023-06-30

Added

  • Fix install or upgrade docker compose command

[1.1.0] - 2023-06-30

Added

  • Add install or upgrade docker compose command

[1.0.18] - 2023-05-04

Fixed

  • Fix project name and directory bugs for create Magento project

[1.0.17] - 2023-01-17

Added

  • Add Magento 2 PWA project creation support

[1.0.16] - 2023-01-04

Added

  • Add Vue Storefront and NuxtJS project creation support

[1.0.15] - 2022-12-16

Added

  • Improve start and stop command to support the specified services

[1.0.14] - 2022-12-15

Added

  • Show or live tail docker container logs

[1.0.13] - 2022-11-18

Added

  • Add switch docker container network command
  • Add edit or show configuration of docker-compose.yml command
  • Update command docs
  • Build publish script

[1.0.12] - 2022-11-10

Added

  • Add create js project command
  • Rebuild restart command for restarts all stopped and running services

[1.0.11] - 2022-11-04

Added

  • Add Webgrind to env list

Fixed

  • Fix yes or no display issue for env list

[1.0.10] - 2022-09-13

Added

  • Add CakePHP, CodeIgniter and Drupal project creation
  • Fix bugs and adjust warning message color

[1.0.9] - 2022-09-09

Added

  • Rebuild create and setup project command
  • Update project creation parameters
  • Add composer auth.json in about command
  • Update use cases

[1.0.8] - 2022-09-08

Added

  • Adjust platforms for init project command
  • Add MariaDB to env table
  • Add sort for env table
  • Add webserver for create project and magento project
  • Add Zend framework to platforms
  • Add status command to list all running containers
  • Add target version to init magento command and make source code is not required
  • Add memcached for env table

[1.0.7] - 2022-09-01

Added

  • Add list envs command and rebuild env handler code
  • Optimize env table and colored current env

[1.0.6] - 2022-08-31

Fixed

  • Fix version convert bug and optimize init magento command

[1.0.5] - 2022-08-30

Added

  • Add conformation when project already exists for initial project
  • Add initial the Magento project command

[1.0.4] - 2022-08-29

Added

  • Add force restart docker services for upgrade
  • Update use cases documents
  • Improve initial project command

[1.0.3] - 2022-08-26

Fixed

  • Fix bugs

[1.0.2] - 2022-08-26

Added

  • Add workspace command
  • Remove GitHub actions
  • Add workspace to init project command

Fixed

  • Fix bug and optimize code

[1.0.1] - 2022-08-23

Added

  • Improve cli
  • Improve documents

Fixed

  • Fix cli bug

[1.0.0] - 2022-08-22

Added

  • Build Shinetech Docker CLI code architecture
  • Implement all functions

Fixed

  • Fix bug: Warning: 'classifiers' should be a list, got type 'tuple'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stdocker-1.2.8.tar.gz (22.4 kB view hashes)

Uploaded Source

Built Distribution

stdocker-1.2.8-py3-none-any.whl (17.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page