├── .gitignore ├── LICENSE ├── README.md ├── certs └── .gitignore ├── installer ├── uninstaller └── upgrade /.gitignore: -------------------------------------------------------------------------------- 1 | /docker-devbox-installer.log 2 | cache/ 3 | bin/ 4 | .bin/ 5 | ddb.yaml 6 | ddb.yml 7 | ddb.local.yaml 8 | ddb.local.yml 9 | 10 | # Ignore child projects 11 | ddb 12 | traefik 13 | portainer 14 | cfssl -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 GFI Centre Ouest 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | docker-devbox 2 | ============= 3 | 4 | Docker Devbox is a set of tools build on top of Docker that automates environments setup for web applications, from 5 | development to production. 6 | 7 | It relies on [ddb](https://inetum-orleans.github.io/docker-devbox-ddb/), a command line tool that provides 8 | features to generate, activate and adjust configuration files based on a single overridable and extendable 9 | configuration, while enhancing the developer experience and reducing manual operations. 10 | 11 | # Design goals 12 | 13 | * Give the developer a clear and native experience, but use docker containers under the hood. 14 | * Isolate each project, but share common patterns and tools. 15 | * Keep control on how containers are built, by keeping `Dockerfile` and `docker-compose.yml` visible and editable. 16 | * Deploy to stage and production environment with no change to the project source code. 17 | * Workaround usual caveats of docker on development environments. 18 | 19 | # Features 20 | 21 | * Activate the project environment automatically when *cd* into the project 22 | folder ([SmartCD](https://github.com/cxreg/smartcd)). 23 | * Access application through `.test` development domain name ([Traefik](https://traefik.io/)). 24 | * Generate trusted SSL certificate automatically through a development certificate 25 | authority ([Cloudflare CFSSL](https://github.com/cloudflare/cfssl) or [mkcert](https://github.com/FiloSottile/mkcert)) 26 | * Install CA certificates automatically to docker images, to support containers SSL inter-communication 27 | and [SSL Corporate proxies](https://security.stackexchange.com/questions/133254/how-does-ssl-proxy-server-in-company-work#answer-133261) 28 | like [Palo Alto SSL Inbound Inspection](https://docs.paloaltonetworks.com/pan-os/7-1/pan-os-admin/decryption/ssl-inbound-inspection.html#) 29 | . 30 | * Brings project containers commands to shell `PATH` and bind current working directory, commands behave as if there 31 | were installed right on the host (For example, `composer install` and `npm install` will just work as usual, `psql` 32 | and `mysql` can connect to the database). 33 | * Fix usual permission issues by automating local volume directory creation 34 | and [fixuid](https://github.com/boxboat/fixuid) integration. 35 | * Configure each target environment (`dev`, `stage`, `prod`) with environment variables only. 36 | * Introduce environment variables into configuration files with a template 37 | engine ([Mo - Mustache Templates in Bash](https://github.com/tests-always-included/mo)). 38 | * Enable configuration files matching the active environment with simple symlinks creation 39 | automation ([mo pure bash templating engine](https://github.com/tests-always-included/mo)). 40 | * Switch to a real public domain name with no pain ([Traefik](https://traefik.io/) 41 | and [Let's Encrypt](https://letsencrypt.org/)). 42 | * Access application from a private network remotely through an automated SSH tunnel ([ngrok](https://ngrok.com/) 43 | , [Serveo](https://serveo.net/) or [ssi.sh](https://github.com/antoniomika/sish)) 44 | 45 | # Requirements 46 | 47 | Docker Devbox runs natively on any Linux only, but Windows and MacOS users may use 48 | [docker-devbox-vagrant](https://github.com/inetum-orleans/docker-devbox-vagrant) to run it inside a Vagrant managed 49 | VirtualBox VM based on Ubuntu Server. 50 | 51 | * Docker >= 18.09.6 52 | * Docker compose plugin >= 2 53 | * GNU Bash >= 4.0 54 | * curl 55 | 56 | # Install or Update 57 | 58 | ``` 59 | curl -L https://github.com/inetum-orleans/docker-devbox/raw/master/installer | bash 60 | ``` 61 | 62 | This will install everything required for Docker Devbox, but docker, docker compose and bash should be installed 63 | manually 64 | before. 65 | 66 | Docker Devbox will install [Traefik](https://traefik.io/) in a docker container and binds `tcp/80`,`tcp/443` to host, 67 | so those ports should be available. 68 | 69 | Port `tcp/7780` should also be available for CFSSL container (local certificate authority service). 70 | 71 | *Installation script may ask for sudo password to install some dependencies, like curl, git and make.* 72 | 73 | ## Development domain name configuration (`.test`) 74 | 75 | To access application through `.test` development domain name, you have to setup your system for those domains to be 76 | resolved as docker host IP. 77 | 78 | On Linux, dnsmasq can be used for this purpose. 79 | 80 | On Windows, Acrylic DNS proxy can be used for this purpose. 81 | 82 | #### Linux (dnsmasq) 83 | 84 | - Ubuntu Server (without NetworkManager) 85 | 86 | ``` 87 | sudo apt-get install -y dnsmasq 88 | 89 | DOCKER_HOST_IP=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+') 90 | sudo sh -c "echo address=/.test/$DOCKER_HOST_IP>/etc/dnsmasq.d/test-domain-to-docker-host-ip" 91 | 92 | sudo service dnsmasq restart 93 | ``` 94 | 95 | - Ubuntu Desktop (with NetworkManager) 96 | 97 | NetworkManager from desktop brings it's own dnsmasq daemon. 98 | 99 | ``` 100 | sudo mv /etc/resolv.conf /etc/resolve.conf.bak 101 | sudo ln -s /var/run/NetworkManager/resolv.conf /etc/resolv.conf 102 | 103 | sudo sh -c 'cat << EOF > /etc/NetworkManager/conf.d/use-dnsmasq.conf 104 | [main] 105 | dns=dnsmasq 106 | EOF' 107 | 108 | sudo sh -c 'cat << EOF > /etc/NetworkManager/dnsmasq.d/test-domain-to-docker-host-ip 109 | address=/.test/$(ip -4 addr show docker0 | grep -Po "inet \K[\d.]+") 110 | EOF' 111 | 112 | sudo service NetworkManager restart 113 | ``` 114 | 115 | #### Windows (Acrylic DNS proxy) 116 | 117 | Download [Acrylic DNS proxy](https://mayakron.altervista.org) for Windows, and perform installation. 118 | 119 | Then open Acrylic UI and configure the Host configuration with such entry 120 | 121 | ``` 122 | 192.168.1.100 *.test 123 | ``` 124 | 125 | The IP address should match the IP of the docker engine. 126 | 127 | ## Configure local CA certificate 128 | 129 | Docker Devbox automatically generates development certificate for HTTPS support, but you need to register the local 130 | CA certificate using mkcert. 131 | 132 | #### Linux 133 | 134 | Run the following commands from docker devbox shell. 135 | 136 | ``` 137 | # This dependency is required to support Chrome and Firefox. 138 | sudo apt-get install libnss3-tools 139 | 140 | # Uninstall any previous CA cert 141 | mkcert -uninstall 142 | 143 | # Move to cfssl container directory 144 | cd ~/.docker-devbox/cfssl 145 | 146 | # Replace default mkcert key/pair with CFSSL public key. 147 | rm -Rf $(mkcert -CAROOT) && mkdir -p $(mkcert -CAROOT) 148 | docker compose cp intermediate:/etc/cfssl/ca.pem $(mkcert -CAROOT)/rootCA.pem 149 | 150 | # Install CFSSL CA Certificate with mkcert. 151 | mkcert -install 152 | ``` 153 | 154 | #### Windows 155 | 156 | On Windows, you should install the CA certificate inside the VM where docker-devbox is installed with the previous 157 | linux procedure, but you should also install the CA certificate on your host, for browser to aknowlegdge the 158 | development certificates. 159 | 160 | - Download [mkcert for Windows](https://github.com/FiloSottile/mkcert/releases), and set `CAROOT` environment variable 161 | to some directory, like `C:\mkcert-ca`. 162 | 163 | - Extract the CFSSL ca certificate from docker with the following command 164 | 165 | ``` 166 | # Inside docker-devbox shell 167 | cd ~/.docker-devbox/cfssl 168 | docker compose cp intermediate:/etc/cfssl/ca.pem ../certs/mkcert-ca/rootCA.pem 169 | ``` 170 | 171 | - Copy `~/.docker-devbox/certs/mkcert-ca/rootCA.pem` to the host, inside `CAROOT` 172 | directory. 173 | 174 | - Close all `cmd.exe`, and open a new one to check that `CAROOT` environment variable is defined. 175 | 176 | ``` 177 | # This should output CAROOT environment variable 178 | mkcert -CAROOT 179 | ``` 180 | 181 | - Install CA certificate 182 | 183 | ``` 184 | mkcert -install 185 | ``` 186 | 187 | ## Installation environment variables 188 | 189 | Environment variables available for installer script: 190 | 191 | - Partial installs: 192 | - `DOCKER_DEVBOX_DISABLE_SMARTCD`: Disable SmartCD. 193 | - `DOCKER_DEVBOX_DISABLE_CFSSL`: Disable CFSSL. 194 | - `DOCKER_DEVBOX_DISABLE_PORTAINER`: Disable portainer. 195 | - `DOCKER_DEVBOX_DISABLE_REVERSE_PROXY`: Disable reverse-proxy feature (traefik). 196 | - `DOCKER_DEVBOX_DISABLE_OPTIONAL_DEPENDENCIES`: Disable the installation of mkcert. 197 | - `DOCKER_DEVBOX_MINIMAL`: Creates the required folder, download the `ddb` binary and create reverse-proxy network only. 198 | Does not install other tools like smartcd, cfssl, portainer, etc. 199 | - `DOCKER_DEVBOX_CI`: Equivalent to `DOCKER_DEVBOX_MINIMAL` and `DOCKER_DEVBOX_DISABLE_OPTIONAL_DEPENDENCIES`, 200 | recommanded for CI. 201 | - Specific version installs: 202 | - `DOCKER_DEVBOX_DDB_VERSION`: Install a specific version of ddb (ex: `v2.0.1`). When unset, gets the latest version 203 | - `DOCKER_DEVBOX_SMARTCD_BRANCH`: Use a specific [smartcd (inetum fork)](https://github.com/inetum-orleans/smartcd) branch. 204 | - `DOCKER_DEVBOX_CFSSL_BRANCH`: Use a specific [docker-devbox-cfssl](https://github.com/inetum-orleans/docker-devbox-cfssl) branch. 205 | - `DOCKER_DEVBOX_PORTAINER_BRANCH`: Use a specific [docker-devbox-portainer](https://github.com/inetum-orleans/docker-devbox-portainer) branch. 206 | - `DOCKER_DEVBOX_TRAEFIK_BRANCH`: Use a specific [docker-devbox-traefik](https://github.com/inetum-orleans/docker-devbox-traefik) branch. 207 | - `DOCKER_DEVBOX_DDB_ASSET_NAME`: Custom [ddb release](https://github.com/inetum-orleans/docker-devbox-ddb/releases) 208 | asset name to install ddb. It was set to "ddb-linux-older-glibc" to install ddb on 209 | older linux distributions, like Ubuntu 16.04. This asset is not compiled anymore, but the option sticked. 210 | You should also add this value to `core.release_asset_name` in ddb 211 | configuration to make `self-update` command download this asset. 212 | - Misc: 213 | - `DOCKER_DEVBOX_CURL_OPTS_GITHUB_API`: Additional curl options to pass when accessing github api. You can set this 214 | variable to `-u ` using a Github Personnal Access Token if you encounter 403 errors due to rate 215 | limiting. 216 | - `DOCKER_DEVBOX_SKIP_DOCKER_CHECKS`: Force installation even if `docker` binary is unavailable. 217 | - `DOCKER_DEVBOX_REVERSE_PROXY_NETWORK`: Name of the reverse proxy network. Default is `reverse-proxy`. 218 | - `DOCKER_DEVBOX_ALLOW_ROOT`: Allow the script to be run as root. This is not recommended. 219 | 220 | Environment variables can be set right before bash invocation in the installer one-liner. 221 | 222 | ```bash 223 | curl -L https://github.com/inetum-orleans/docker-devbox/raw/master/installer | \ 224 | DOCKER_DEVBOX_CI=1 \ 225 | bash 226 | ``` 227 | -------------------------------------------------------------------------------- /certs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /installer: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | DOCKER_DEVBOX_HOME="${DOCKER_DEVBOX_HOME:-$HOME/.docker-devbox}" 4 | DOCKER_DEVBOX_BIN="${DOCKER_DEVBOX_HOME}/bin" 5 | DOCKER_DEVBOX_DOT_BIN="${DOCKER_DEVBOX_HOME}/.bin" 6 | export DOCKER_DEVBOX_REVERSE_PROXY_NETWORK="${DOCKER_DEVBOX_REVERSE_PROXY_NETWORK:-reverse-proxy}" 7 | DOCKER_DEVBOX_DDB_ASSET_NAME="${DOCKER_DEVBOX_DDB_ASSET_NAME:-ddb-linux}" 8 | 9 | if [[ -n "${DOCKER_DEVBOX_CI}" ]]; then 10 | DOCKER_DEVBOX_MINIMAL=1 11 | DOCKER_DEVBOX_DISABLE_OPTIONAL_DEPENDENCIES=1 12 | fi 13 | 14 | if [[ -z "${DOCKER_DEVBOX_MINIMAL}" ]]; then 15 | DOCKER_DEVBOX_SMARTCD_BRANCH="${DOCKER_DEVBOX_SMARTCD_BRANCH:-master}" 16 | DOCKER_DEVBOX_CFSSL_BRANCH="${DOCKER_DEVBOX_CFSSL_BRANCH:-master}" 17 | DOCKER_DEVBOX_PORTAINER_BRANCH="${DOCKER_DEVBOX_PORTAINER_BRANCH:-master}" 18 | DOCKER_DEVBOX_TRAEFIK_BRANCH="${DOCKER_DEVBOX_TRAEFIK_BRANCH:-master}" 19 | fi 20 | 21 | if [[ -n "${DOCKER_DEVBOX_DISABLE_SMARTCD}" ]]; then 22 | DOCKER_DEVBOX_SMARTCD_BRANCH="" 23 | fi 24 | 25 | if [[ -n "${DOCKER_DEVBOX_DISABLE_CFSSL}" ]]; then 26 | DOCKER_DEVBOX_CFSSL_BRANCH="" 27 | fi 28 | 29 | if [[ -n "${DOCKER_DEVBOX_DISABLE_PORTAINER}" ]]; then 30 | DOCKER_DEVBOX_PORTAINER_BRANCH="" 31 | fi 32 | 33 | if [[ -n "${DOCKER_DEVBOX_DISABLE_REVERSE_PROXY}" ]]; then 34 | DOCKER_DEVBOX_TRAEFIK_BRANCH="" 35 | fi 36 | 37 | mkdir -p "${DOCKER_DEVBOX_HOME}" 38 | 39 | _LOG="${DOCKER_DEVBOX_HOME}/docker-devbox-installer.log" 40 | 41 | echo "">"$_LOG" 42 | 43 | if [[ -d "$DOCKER_DEVBOX_HOME/cache" ]]; then 44 | echo "Clearing cache from previous installation" 2>&1 |& tee -a "$_LOG" 45 | rm -rf "$DOCKER_DEVBOX_HOME/cache" &>> "$_LOG" 46 | fi 47 | 48 | if [[ $EUID -eq 0 ]] && [[ -z "${DOCKER_DEVBOX_ALLOW_ROOT}" ]] 49 | then 50 | echo "Please run as non-root user or set DOCKER_DEVBOX_ALLOW_ROOT environment variable." 2>&1 | tee -a "$_LOG" 51 | exit 1 52 | fi 53 | 54 | if [[ $EUID -eq 0 ]]; then 55 | SUDO_EXE="" 56 | else 57 | SUDO_EXE=$(command -v sudo) 58 | if [[ ! -x "$SUDO_EXE" ]]; then 59 | echo "sudo is not available." 2>&1 | tee -a "$_LOG" 60 | fi 61 | fi 62 | 63 | if [[ -z "${DOCKER_DEVBOX_SKIP_DOCKER_CHECKS}" ]] && [[ ! -x $(command -v docker) ]]; then 64 | echo "Please install docker before installing docker devbox." 65 | exit 1 66 | fi 67 | 68 | if [[ -n "$(command -v apt-get)" ]]; then 69 | PACKAGE_INSTALL_COMMAND="apt-get -y install" 70 | elif [[ -n "$(command -v yum)" ]]; then 71 | PACKAGE_INSTALL_COMMAND="yum -y install" 72 | elif [[ -n "$(command -v apk)" ]]; then 73 | PACKAGE_INSTALL_COMMAND="apk add" 74 | else 75 | PACKAGE_INSTALL_COMMAND="" 76 | fi 77 | 78 | _install_package_if_missing() { 79 | local PACKAGE="$1" 80 | 81 | if [[ ! -x $(command -v "$PACKAGE") ]]; then 82 | if [[ ! -x "$SUDO_EXE" && $EUID -ne 0 ]]; then 83 | echo "Sudo is not available to install $PACKAGE. Install '$PACKAGE' package manually and run the installer again." 84 | exit 1 85 | fi 86 | if [[ -z "$PACKAGE_INSTALL_COMMAND" ]]; then 87 | echo "No package manager found to install $PACKAGE. Install '$PACKAGE' package manually and run the installer again." 88 | exit 1 89 | fi 90 | 91 | echo "Install $PACKAGE" 2>&1 | tee -a "$_LOG" 92 | $SUDO_EXE $PACKAGE_INSTALL_COMMAND $PACKAGE &>> "$_LOG" 93 | fi 94 | } 95 | 96 | _install_package_if_missing "git" 97 | _install_package_if_missing "make" 98 | 99 | mkdir -p $DOCKER_DEVBOX_BIN 100 | mkdir -p $DOCKER_DEVBOX_DOT_BIN 101 | 102 | if [[ -f "$HOME/.bashrc" ]]; then 103 | cat "$HOME/.bashrc" | grep "export PATH=\"$DOCKER_DEVBOX_BIN:$DOCKER_DEVBOX_DOT_BIN:\$PATH\"" &> /dev/null 104 | BASH_RC_CONFIGURED=$? 105 | if [[ "$BASH_RC_CONFIGURED" -ne 0 ]]; then 106 | echo "Add $DOCKER_DEVBOX_BIN and $DOCKER_DEVBOX_DOT_BIN to path (.bashrc)" 2>&1 |& tee -a "$_LOG" 107 | 108 | cat << EOF >> "$HOME/.bashrc" 109 | 110 | # Add docker-devbox bin to PATH 111 | export PATH="$DOCKER_DEVBOX_BIN:$DOCKER_DEVBOX_DOT_BIN:\$PATH" 112 | EOF 113 | fi 114 | elif [[ -f "$HOME/.bash_profile" ]]; then 115 | cat "$HOME/.bash_profile" | grep "export PATH=\"$DOCKER_DEVBOX_BIN:$DOCKER_DEVBOX_DOT_BIN:\$PATH\"" &> /dev/null 116 | BASH_PROFILE_CONFIGURED=$? 117 | if [[ "$BASH_PROFILE_CONFIGURED" -ne 0 ]]; then 118 | echo "Add $DOCKER_DEVBOX_BIN and $DOCKER_DEVBOX_DOT_BIN to path (.bash_profile)" 2>&1 |& tee -a "$_LOG" 119 | 120 | cat << EOF >> "$HOME/.bash_profile" 121 | 122 | # Add docker-devbox bin to PATH 123 | export PATH="$DOCKER_DEVBOX_BIN:$DOCKER_DEVBOX_DOT_BIN:\$PATH" 124 | EOF 125 | fi 126 | fi 127 | 128 | export PATH="$DOCKER_DEVBOX_BIN:$PATH" 129 | 130 | if [[ -n "${DOCKER_DEVBOX_DDB_VERSION}" ]]; then 131 | echo "Downloading ddb version ${DOCKER_DEVBOX_DDB_VERSION}" 2>&1 |& tee -a "$_LOG" 132 | DOCKER_DEVBOX_BIN_URL="https://github.com/inetum-orleans/docker-devbox-ddb/releases/download/${DOCKER_DEVBOX_DDB_VERSION}/${DOCKER_DEVBOX_DDB_ASSET_NAME}" 133 | else 134 | echo "Downloading ddb latest release" 2>&1 |& tee -a "$_LOG" 135 | DOCKER_DEVBOX_BIN_URL=$(curl -fsSL $DOCKER_DEVBOX_CURL_OPTS_GITHUB_API https://api.github.com/repos/inetum-orleans/docker-devbox-ddb/releases/latest \ 136 | | grep "browser_download_url.*/$DOCKER_DEVBOX_DDB_ASSET_NAME\"" \ 137 | | cut -d : -f 2,3 \ 138 | | tr -d \") 139 | 140 | if [[ -z "${DOCKER_DEVBOX_BIN_URL}" ]]; then 141 | # Github API may fail, most commonly because of unauthenticated rate limit. 142 | # Use git to retrieve latest release tag and build url manually. 143 | DOCKER_DEVBOX_LATEST_RELEASE=$(git -c 'versionsort.suffix=-' \ 144 | ls-remote --exit-code --refs --sort='version:refname' --tags https://github.com/inetum-orleans/docker-devbox-ddb 'v*.*.*' \ 145 | | tail --lines=1 \ 146 | | cut --delimiter='/' --fields=3) 147 | 148 | if [[ -z "${DOCKER_DEVBOX_LATEST_RELEASE}" ]]; then 149 | echo "Can't find docker-devbox-ddb last release." 2>&1 | tee -a "$_LOG" 150 | exit 1 151 | fi 152 | 153 | DOCKER_DEVBOX_BIN_URL="https://github.com/inetum-orleans/docker-devbox-ddb/releases/download/${DOCKER_DEVBOX_LATEST_RELEASE}/${DOCKER_DEVBOX_DDB_ASSET_NAME}" 154 | fi 155 | fi 156 | 157 | curl -fsSL -o "$DOCKER_DEVBOX_BIN/ddb" $DOCKER_DEVBOX_BIN_URL 158 | chmod +x "$DOCKER_DEVBOX_BIN/ddb" 159 | 160 | if [[ -z "${DOCKER_DEVBOX_DISABLE_OPTIONAL_DEPENDENCIES}" ]]; then 161 | _MKCERT_VERSION=$(curl -fsSL $DOCKER_DEVBOX_CURL_OPTS_GITHUB_API https://api.github.com/repos/FiloSottile/mkcert/releases/latest | grep 'tag_name' | cut -d\" -f4) 162 | _MKCERT_INSTALL=1 163 | if [[ -f "$DOCKER_DEVBOX_BIN"/.mkcert.version ]]; then 164 | if [[ $(cat "$DOCKER_DEVBOX_BIN"/.mkcert.version) == "${_MKCERT_VERSION}" ]]; then 165 | _MKCERT_INSTALL=0 166 | fi 167 | fi 168 | 169 | if [[ "$_MKCERT_INSTALL" -ne 0 ]]; then 170 | _install_package_if_missing "curl" 171 | 172 | echo "Install mkcert ($_MKCERT_VERSION)" 2>&1 |& tee -a "$_LOG" 173 | curl -fsSL -o "$DOCKER_DEVBOX_BIN"/mkcert "https://github.com/FiloSottile/mkcert/releases/download/$_MKCERT_VERSION/mkcert-$_MKCERT_VERSION-linux-amd64" &>> "$_LOG" 174 | chmod +x "$DOCKER_DEVBOX_BIN"/mkcert &>> "$_LOG" 175 | 176 | echo "$_MKCERT_VERSION" >> "$DOCKER_DEVBOX_BIN"/.mkcert.version 177 | fi 178 | fi 179 | 180 | echo "Create $DOCKER_DEVBOX_REVERSE_PROXY_NETWORK docker network" 2>&1 |& tee -a "$_LOG" 181 | docker network create "$DOCKER_DEVBOX_REVERSE_PROXY_NETWORK" &>> "$_LOG" || true 182 | 183 | if [[ -n "${DOCKER_DEVBOX_SMARTCD_BRANCH}" ]]; then 184 | echo "Install SmartCD" 2>&1 |& tee -a "$_LOG" 185 | cd /tmp &>> "$_LOG" 186 | rm -Rf smartcd &>> "$_LOG" 187 | git clone -b ${DOCKER_DEVBOX_SMARTCD_BRANCH} https://github.com/inetum-orleans/smartcd.git &>> "$_LOG" 188 | cd smartcd &>> "$_LOG" 189 | make install &>> "$_LOG" 190 | source load_smartcd &>> "$_LOG" 191 | rm -Rf smartcd &>> "$_LOG" 192 | cd $HOME &>> "$_LOG" 193 | 194 | if [[ ! -f "$HOME/.smartcd_config" ]]; then 195 | cat << 'EOF' > $HOME/.smartcd_config 196 | # Load and configure smartcd 197 | source $HOME/.smartcd/lib/core/arrays 198 | source $HOME/.smartcd/lib/core/varstash 199 | source $HOME/.smartcd/lib/core/smartcd 200 | # smartcd setup chpwd-hook 201 | smartcd setup cd 202 | smartcd setup pushd 203 | smartcd setup popd 204 | # smartcd setup prompt-hook 205 | # smartcd setup exit-hook 206 | smartcd setup completion 207 | # VARSTASH_AUTOCONFIGURE=1 208 | # VARSTASH_AUTOEDIT=1 209 | # SMARTCD_NO_INODE=1 210 | # SMARTCD_AUTOMIGRATE=1 211 | SMARTCD_LEGACY=1 212 | SMARTCD_QUIET=1 213 | # VARSTASH_QUIET=1 214 | EOF 215 | echo "SmartCD configuration file has been written (~/.smartcd_config)" 2>&1 |& tee -a "$_LOG" 216 | fi 217 | 218 | cat $HOME/.bashrc | grep .smartcd_config &> /dev/null 219 | BASHRC_CONFIGURED=$? 220 | if [[ "$BASHRC_CONFIGURED" -ne 0 ]]; then 221 | cat << 'EOF' >> "$HOME/.bashrc" 222 | 223 | # SmartCD Configuration 224 | [ -r "$HOME/.smartcd_config" ] && ( [ -n $BASH_VERSION ] || [ -n $ZSH_VERSION ] ) && source $HOME/.smartcd_config 225 | EOF 226 | echo "SmartCD registered (~/.bashrc)" 2>&1 |& tee -a "$_LOG" 227 | fi 228 | else 229 | echo "SmartCD is disabled" 2>&1 |& tee -a "$_LOG" 230 | fi 231 | 232 | # Traefik 233 | if [[ -d "$DOCKER_DEVBOX_HOME/traefik" ]]; then 234 | echo "Traefik : removing existing traefik installation" &>> "$_LOG" 235 | echo "Stop traefik" 2>&1 |& tee -a "$_LOG" 236 | cd "$DOCKER_DEVBOX_HOME/traefik" &>> "$_LOG" 237 | docker compose down --remove-orphans --volumes &>> "$_LOG" 238 | cd $HOME &>> "$_LOG" 239 | rm -rf "$DOCKER_DEVBOX_HOME"/traefik &>> "$_LOG" 240 | rm -rf "$DOCKER_DEVBOX_HOME"/certs &>> "$_LOG" 241 | fi 242 | 243 | if [[ -n "${DOCKER_DEVBOX_TRAEFIK_BRANCH}" ]]; then 244 | 245 | echo "Use traefik as reverse proxy" 2>&1 |& tee -a "$_LOG" 246 | git clone -b ${DOCKER_DEVBOX_TRAEFIK_BRANCH} https://github.com/inetum-orleans/docker-devbox-traefik.git "$DOCKER_DEVBOX_HOME/traefik" &>> "$_LOG" 247 | cd "${DOCKER_DEVBOX_HOME}"/traefik &>> "$_LOG" 248 | echo "Install traefik" 2>&1 |& tee -a "$_LOG" 249 | touch acme.json 250 | mkdir -p "$DOCKER_DEVBOX_HOME"/certs 251 | ddb configure &>> "$_LOG" || true 252 | docker compose pull &>> "$_LOG" || true 253 | echo "Start traefik" 2>&1 |& tee -a "$_LOG" 254 | docker compose up --build -d &>> "$_LOG" 255 | cd $HOME &>> "$_LOG" 256 | else 257 | echo "Reverse proxy is disabled" 2>&1 |& tee -a "$_LOG" 258 | fi 259 | 260 | # CFSSL 261 | if [[ -d "$DOCKER_DEVBOX_HOME/cfssl" ]]; then 262 | echo "CFSSL : removing existing cfssl installation" &>> "$_LOG" 263 | echo "Stop CFSSL" 2>&1 |& tee -a "$_LOG" 264 | cd "$DOCKER_DEVBOX_HOME/cfssl" &>> "$_LOG" 265 | docker compose down --remove-orphans --volumes &>> "$_LOG" 266 | cd $HOME &>> "$_LOG" 267 | rm -rf "$DOCKER_DEVBOX_HOME"/cfssl &>> "$_LOG" 268 | fi 269 | 270 | if [[ -n "${DOCKER_DEVBOX_CFSSL_BRANCH}" ]]; then 271 | echo "Install CFSSL" 2>&1 |& tee -a "$_LOG" 272 | git clone -b ${DOCKER_DEVBOX_CFSSL_BRANCH} https://github.com/inetum-orleans/docker-devbox-cfssl.git "$DOCKER_DEVBOX_HOME/cfssl" &>> "$_LOG" 273 | cd "${DOCKER_DEVBOX_HOME}"/cfssl &>> "$_LOG" 274 | ddb configure &>> "$_LOG" 275 | docker compose pull &>> "$_LOG" 276 | echo "Start CFSSL" 2>&1 |& tee -a "$_LOG" 277 | docker compose up --build -d &>> "$_LOG" 278 | else 279 | echo "CFSSL is disabled" 2>&1 |& tee -a "$_LOG" 280 | fi 281 | 282 | # Portainer 283 | if [[ -d "$DOCKER_DEVBOX_HOME/portainer" ]]; then 284 | echo "Portainer : removing existing portainer installation" &>> "$_LOG" 285 | echo "Stop portainer" 2>&1 |& tee -a "$_LOG" 286 | cd "$DOCKER_DEVBOX_HOME/portainer" &>> "$_LOG" 287 | docker compose down --remove-orphans --volumes &>> "$_LOG" 288 | cd $HOME &>> "$_LOG" 289 | rm -rf "$DOCKER_DEVBOX_HOME"/portainer &>> "$_LOG" 290 | fi 291 | 292 | if [[ -n "${DOCKER_DEVBOX_PORTAINER_BRANCH}" ]]; then 293 | echo "Install portainer" 2>&1 |& tee -a "$_LOG" 294 | git clone -b ${DOCKER_DEVBOX_PORTAINER_BRANCH} https://github.com/inetum-orleans/docker-devbox-portainer.git "$DOCKER_DEVBOX_HOME/portainer" &>> "$_LOG" 295 | cd "${DOCKER_DEVBOX_HOME}"/portainer &>> "$_LOG" 296 | ddb configure &>> "$_LOG" || true 297 | docker compose pull &>> "$_LOG" || true 298 | echo "Start portainer" 2>&1 |& tee -a "$_LOG" 299 | docker compose up --build -d &>> "$_LOG" 300 | else 301 | echo "Portainer is disabled" 2>&1 |& tee -a "$_LOG" 302 | fi 303 | 304 | echo "Docker Devbox installation is terminated." 2>&1 |& tee -a "$_LOG" 305 | 306 | 307 | if [[ -f $HOME/.smartcd_config ]]; then 308 | source $HOME/.smartcd_config 309 | fi 310 | -------------------------------------------------------------------------------- /uninstaller: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Uninstaller for Docker Devbox 3 | # This script is intended to be run as a non-root user 4 | # You can run it like this: 5 | # curl -L https://github.com/inetum-orleans/docker-devbox/raw/master/uninstaller | bash 6 | 7 | if [[ $EUID -eq 0 ]] 8 | then 9 | echo "Please run as non-root user." 10 | exit 1 11 | fi 12 | 13 | DOCKER_DEVBOX_HOME="${DOCKER_DEVBOX_HOME:-$HOME/.docker-devbox}" 14 | 15 | if [[ ! -d "$DOCKER_DEVBOX_HOME" ]] 16 | then 17 | echo "Docker devbox not found at $DOCKER_DEVBOX_HOME" 18 | exit 1 19 | fi 20 | 21 | echo "Removing docker devbox installed at $DOCKER_DEVBOX_HOME" 22 | 23 | SERVICES=("cfssl" "portainer" "traefik") 24 | for SERVICE in "${SERVICES[@]}"; do 25 | if [[ -d "${DOCKER_DEVBOX_HOME}/${SERVICE}" ]] 26 | then 27 | cd "${DOCKER_DEVBOX_HOME}/${SERVICE}" && docker compose down -v --remove-orphans 28 | fi 29 | done 30 | 31 | cd $HOME 32 | rm -Rf "$HOME/.smartcd" 33 | rm -Rf "$HOME/.smartcd_config" 34 | rm -Rf "${DOCKER_DEVBOX_HOME}" 35 | 36 | echo "Docker devbox is uninstalled. We will miss you!" 37 | echo "Please not that some PATH variable configuration might still be remaining in your .bashrc/.bash_profile" -------------------------------------------------------------------------------- /upgrade: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Upgrade script for Docker Devbox 3 | # This script is intended to be run as a non-root user 4 | # You can run it like this: 5 | # curl -L https://github.com/inetum-orleans/docker-devbox/raw/master/upgrade | bash 6 | 7 | if [[ $EUID -eq 0 ]] 8 | then 9 | echo "Please run as non-root user." 10 | exit 1 11 | fi 12 | 13 | DOCKER_DEVBOX_HOME="${DOCKER_DEVBOX_HOME:-$HOME/.docker-devbox}" 14 | 15 | ddb self-update 16 | 17 | SERVICES=("cfssl" "portainer" "traefik") 18 | for SERVICE in "${SERVICES[@]}"; do 19 | if [[ -d "${DOCKER_DEVBOX_HOME}/${SERVICE}" ]] 20 | then 21 | cd "${DOCKER_DEVBOX_HOME}/${SERVICE}" &&\ 22 | git pull &&\ 23 | ddb configure &&\ 24 | docker compose up -d --pull always 25 | fi 26 | done --------------------------------------------------------------------------------