Docker

Getting Started


Introduction

Using Docker is a quick and easy way to run AsgardCMS in containers. By using Docker you will not need to install PHP, MySQL or a web server directly on your machine!

To get Docker installed, either read below or alternatively watch Install AsgardCMS with Docker.

Prerequisites

To be able to run AsgardCMS under docker you will need:

Install AsgardCMS

Database configuration

Docker will create a MySQL container with a new database for you automatically.

Be sure to set the database name, username, password you want to use in docker-compose.yml

Run the containers

A helper tool called dcp exists in the root of the project. You may need to give it executable permissions before using it (chmod +x ./dcp).

Start the containers with this command.

./dcp up

If this is your first time running this command, it may take a little while to download/build the images.

Acquire dependencies

To install / update dependencies you may run a composer command (if this is the first time, this step is mandatory).

Run ./dcp composer install to install or ./dcp composer update to update your dependencies.

Run the install command

Now run the ./dcp artisan asgard:install command to perform the AsgardCMS installation process.

When prompted for database credentials, use the details you specified in the docker-compose.yml file.

When asked for the mysql host, use the name of the mysql container from docker-compose.yml (by default mysql).

Enjoy

You can now login on http://localhost/auth/login with the email and password you entered during the install command. After you've logged in you'll be able to access the administration panel by visiting http://localhost/backend.

Working with the containers

You will need to use the ./dcp command when interacting with the container.

The most common commands you will need are:

  • ./dcp: Check the status of the containers
  • ./dcp up: Bring up the containers
  • ./dcp down: Stop the containers
  • ./dcp rs: Restart the containers
  • ./dcp composer: Run composer in the container
  • ./dcp artisan or ./dcp art or ./dcp a: Run the artisan command
  • ./dcp test: Run phpunit in a new container
  • ./dcp t: Run phpunit in the app container
  • ./dcp yarn: Run yarn
  • ./dcp npm: Run npm

For most of the above commands any arguments you enter after the command will be passed to the original command, for example running ./dcp artisan migrate would run php artisan migrate and ./dcp test Modules/Core/Tests would run PHPUnit for the Core module.

Rebuilding the image

Whenever you make a change to the Dockerfile files, you will have to rebuild the images for the changes to take effect. This can be done with:

  • ./dcp build
  • ./dcp rs

Xdeb

Xdebug is turned on by default and is configured for Docker For Mac.

To switch it off or adjust for a different platform, edit /docker/app/enabled-xdebug.ini.

After making xdebug changes, you will need to rebuild the images for the containers. Run ./dcp build to rebuild the images, followed by ./dcp rs to restart the containers.

Blackfire.io

AsgardCMS docker setup comes with a Blackfire.io container which contains the Blackfire Agent. The app container comes with the Blackfire probe set up by default.

To set it up, you need to fill in the server keys in docker-compose.yml file:

blackfire:
image: blackfire/blackfire
environment:
  BLACKFIRE_SERVER_ID:
  BLACKFIRE_SERVER_TOKEN:
networks:
- asgard_net

Getting help

If you have feedback to give, ideas you would like implemented, by all means share them on the forum in the "Comments and Feedback" section.

For issues/bugs you're having, you can use the Github Issues to post those. All issues are grouped on the AsgardCms/Platform repository.

If you just want to talk, join our Slack channel (http://slack.asgardcms.com/).

Mobile Analytics