ByteInternet / hypernode-docker

Fast and easy Docker for Magento development
https://community.hypernode.io/hypernode-docker
35 stars 8 forks source link

hypernode-docker

The official Hypernode Docker image for Magento development. This image can be used to set up a fast and easy local development environment for Hypernode, or as a build machine in a CI environment representative of the production environment. The image contains the exact same packages and configuration as a real Hypernode except for some Docker specific tweaks. By testing and developing against this image you can be sure that when you deploy to a Hypernode in production there will be no surprises because of different software versions or configurations.

We build this image multiple times a day (every time we do a release) by applying our configuration management on the phusion/baseimage-docker 'fat' container. By treating the Docker as a lightweight VM instead of as a vehicle for a single process we stay close to what an actual Hypernode actually looks like. No micro-services or a multi-container application, but a single instance with minimal network overhead and all batteries included.

The hypernode-docker image has SSH, PHP, NGINX, MySQL, Redis and Varnish. The biggest difference between a real Hypernode and this container is that this environment does not have an init system. While it is possible to run systemd within a Docker Container if the host is also runs systemd, we choose not to do so to achieve greater compatibility and user-friendliness.

Usage

Note about performance

We have tested usage of the Hypernode Docker image on Apple silicon ourselves and have found while it works out of the box, performance is unfortunately suboptimal (our current measures show 35 seconds of load time for a stock Magento homepage). If this performance drawback is fine for you, go ahead with it. If you need more performance when using the Hypernode Docker image, we recommend running the Docker image on a system that can run the image natively, like a workstation/laptop with an Intel or AMD processor. You could even run these images on a server with an AMD/Intel processor. And manage the test environments remotely through SSH, SFTP along with tools like VSCode.

The Debian Buster hypernode-docker

Starting the container

docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker:latest
docker run docker.hypernode.com/byteinternet/hypernode-buster-docker:latest

Now with the introduction of Debian Buster we have also made it so that for some of the possible configurations we have provided a pre-built image so it is not necessary anymore to manually install a different MySQL for example than what would be in the default box.

These are the URLs of the containers with specific configurations:

docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php56-mysql56:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php70-mysql56:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php71-mysql56:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php72-mysql56:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php73-mysql56:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php74-mysql56:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php80-mysql56:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php81-mysql56:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php56-mysql57:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php70-mysql57:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php71-mysql57:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php72-mysql57:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php73-mysql57:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php74-mysql57:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php80-mysql57:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php81-mysql57:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php82-mysql57:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php56-mysql80:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php70-mysql80:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php71-mysql80:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php72-mysql80:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php73-mysql80:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php74-mysql80:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php80-mysql80:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php81-mysql80:latest
docker pull docker.hypernode.com/byteinternet/hypernode-buster-docker-php82-mysql80:latest

Logging into the container

Get the IP address

# Find the container ID
docker ps
# Find the IP address of the container
docker inspect -f '{{ .NetworkSettings.IPAddress }}' <the container ID>

Log in to the container:

# SSH into the machine using the retrieved IP address. Example:
ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null app@172.17.0.2
# Or as the root user
ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null root@172.17.0.2

The password is insecure_docker_ssh_password, or use the pregenerated key.

Restarting services

Because systemctl is not available inside the container, the services are started by an init script on container startup. Note that because the systemd unit files are not parsed there could be a slight drift between what commandline flags the processes actually use in production compared to in this contanier.

To restart all services run:

bash /etc/my_init.d/60_restart_services.sh

If you only want to restart a specific service, inspect the restart_services.sh script and kill the screen for the service you want to restart. Then run the corresponding screen command to start the service again.

See our excellent Documentation!

Starting the container

Importing an existing Magento shop into the Docker

Switching PHP versions

Debugging with Xdebug in PhpStorm

Adding your own keys to the container

Inspecting emails sent from the Docker

Installing Magento 1

Mac specific example

Inspiration

If you're wondering about how you can make best use of this image, check out some of these awesome project(s) by other users.

Disposable Magento testing environments with Kubernetes

Peter Jaap Blaakmeer explains how Elgentos automatically sets up disposable testing environments for branches, tags and commits in their repositories by deploying the hypernode-docker image on a Kubernetes cluster on the Google Cloud Platform.

Local development with the Hypernode Docker container

Ruthger Idema describes how Guapa mimics their production environments as close as possible when developing on their local machines. Also includes a nice example for setting up Xdebug to work with PHPstorm in the hypernode-docker.

WSL development environment for Hypernode Docker

Fabio Ros over at FROSIT created a fully-featured WSL development environment that integrates nicely with WSL on your Windows PC and your PHPStorm/VSCode editor. Check out the sourcecode and how to set this up over at the open-source hypernode-docker-wsl2 repository.

Related projects

hypernode-vagrant

A similar local development or build environment based on Vagrant, using Virtualbox VMs or LXC containers. The difference between hypernode-docker and hypernode-vagrant is that the Vagrant has a complete init system, making it more like a real Hypernode, while the Docker could be more user-friendly depending on your environment and preferences.

hypernode-deployment-hackathon

A work in progress Magento 2 module built by the community that can be used as a building block in combination with the Docker container in this repository to simplify the testing, building and deployment steps in your CI pipeline.