Workspace Container


About

The workspace container is the central location to interact with your applications through a terminal. It can be used for running tests, running migrations, installing new composer dependencies, or running front-end NPM scripts. When developing inside of a container, your Workspace container should be the container you connect to. If you're using VS Code, you can learn more about connecting to this container, here.

Settings

Name Default Description
PHP Version 8.2 The PHP version to use for your application.
Composer Version 2 The Composer version to install in the workspace.
Node Version 18 The Node version to install in the workspace.
Volume Flag :delegated How Docker will handle file synchronizations for your application directory. :delegated provides a slight performance improvement if you are developing inside the container.
Hot Module Replacement Port 5173 The port to expose from your workspace when running Hot Module Replacement (HMR).
Install XDebug Extension No Installs XDebug in your Workspace for debugging or running code coverage.
Install PCOV No When you don't want the added complexity of XDebug, PCOV provides a faster alternative for compiling code coverage.
Install SSH2 Extension No Specify if you want the SSH2 PHP extension installed.
Install XSL Extension No Specify if you want the XSL PHP extension installed.
Install Stripe CLI No If you plan on processing payments in your application, the Stripe CLI can be used to setup listeners for webhooks.

Entering the Workspace

If you need to run a command inside of your workspace, you can enter your Workspace container in a terminal by navigating to the AppIgnition dashboard, opening the menu for the application you installed, and selecting Open in Terminal.

Application menu

You can do this manually by executing the following in a terminal as well:

cd path-to-workspace-folder/app-ignition-laradock
docker compose exec --user=ignition -w "/var/www/" workspace fish

While there isn't much need to, unless you're installing additional software in the environment, you can enter the Workspace as the root user running the following:

cd path-to-workspace-folder/app-ignition-laradock
docker compose exec --user=root -w "/var/www/" workspace fish

Just be sure the container is running.

Fish Shell

You'll notice in the previous section we're executing the application fish to enter the Workspace container. Fish Shell has been chosen as the default shell for the Workspace container due to its helpful autosuggestions, its various color schemes, its simplicity, and its speed. However, you can still use a bash shell by changing fish to bash with the command in the previous section.

Since Fish's syntax is slightly different from bash, a utility has been installed in the workspace called bass that can be used to run native bash commands. For instance, take the following command.

export X=3

Using bass, we can run it like this:

bass export X=3

Connecting to Other Containers

At times, you may want to connect to your other containers from the workspace container to debug, troubleshoot, or interact with the software in some manor through a terminal. Since all of your containers are automatically networked together, this is possible with one consideration. To better explain, lets take a look at a common scenario where you want to import a database dump into a MySQL database.

  1. The first thing you want to do is make sure the database dump file is located on the container's filesystem so you have access to it in your Workspace. There are methods to move files from your local machine onto a container using Docker in a terminal, but since our application is mounted as a volume in the Workspace container, my personal recommendation is to move the file on your local machine into your application's directory.

  2. Now lets say you have a database created in the MySQL container, called my_blog, and you want to import an anonymized database dump into it to troubleshoot a bug found in production. To do this, you can run the following in your Workspace container:

    mysql -h mysql -u root -p my_blog < anonymized_dump.sql

    You'll notice we're specifying the host of our database to be mysql, rather than the expected 127.0.0.1. This is because if we were to use 127.0.0.1 from the Workspace container, it will look for a database server on the Workspace container rather than the intended MySQL container.


To determine the hostname you should use when connecting to any of your other containers, you can find it under the Containers grid in AppIgnition under Hostname.

Container hostname

Aliases

The following aliases have been made available to you in the Workspace container to ease common development tasks.

# Common aliases
alias home="cd ~"
alias code="cd /var/www"

# grep aliases
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'

# composer aliases
alias cdump="composer dump-autoload -o"
alias composer:dump="composer dump-autoload -o"

# artisan aliases
alias artisan="php artisan"
alias db:reset="php artisan migrate:reset && php artisan migrate --seed"
alias dusk="php artisan dusk"
alias vapor="php vendor/bin/vapor"
alias fresh="php artisan migrate:fresh"
alias migrate="php artisan migrate"
alias refresh="php artisan migrate:refresh"
alias rollback="php artisan migrate:rollback"
alias seed="php artisan db:seed"

# phpunit aliases
alias phpunit="./vendor/bin/phpunit"

# npm aliases
alias npm-global="npm list -g --depth 0"
alias run="npm run"

# git aliases
alias gaa="git add ."
alias gd="git --no-pager diff"
alias git-revert="git reset --hard && git clean -df"
alias gs="git status"
alias gsh="git show"
alias grb="git rebase -i"
alias gbr="git branch"
alias gc="git commit"
alias gck="git checkout"