Home | About | Blog | Interesting Reads | Tutorials | Skills | Personal Projects | Books | Fun | Connect with me
Published On: Aug 09 2021
Written By: Krishnan Sethuraman
Category: DevOps
This blog and website is built on PhalconPHP and to initially set it up I had to run multiple configurations to get it up and running on my localhost as well as on my server. This was complicated to start with and imagine if I’m trying out multiple frameworks from different languages then making specific configurations for each one of them would become a nightmare.
So I decided to give Docker a try.
To start with I watched the following Docker tutorial on Youtube. It was wonderful and gave me exactly what I wanted (which was to learn Docker from a developer’s perspective).
Docker Tutorial for Beginners [FULL COURSE in 3 Hours]
Once I understood the basic concepts of Docker, I installed Docker on my computer.
After that I googled for a PhalconPHP docker image that I could use as a starting point. My search landed me to the following medium article which explained setting up PhalconPHP Docker containers. I simply followed the article.
Working with Phalcon Framework and Docker
Once I had Phalcon application setup I closed the containers. $ docker-compose down
I use mysql with this website and hence needed a volume to store the database. $ docker volume create --name=volumename
To confirm if the volume got created.$ docker volume ls
Then I opened docker-compose.yml and made the following changes. version: '3'
services:
app:
container_name: app
build: .
working_dir: /var/www/html
volumes:
- ./:/var/www/html
ports:
- '5000:80' {port of my choice}
expose:
- '5000'
mysql:
image: mysql:8
container_name: app-db
volumes:
- volumename:/var/lib/mysql #Added volumes for persistent data storage
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: {DB Name}
ports:
- '3307:3306' {port of my choice}
environment:
- ALLOW_EMPTY_PASSWORD=yes
volumes:
volumename:
I saved the file and created Docker containers again. $ docker-compose up -d
I checked to see if the docker containers got created,
$ docker ps
The containers should get created with the container name that you chose in the docker-compose.yml file.
I could login into the containers by typing,
$ docker exec -it app /bin/bash
$ docker exec -it app-db /bin/bash
This should setup PhalconPHP in Docker containers and you can now easily bring in your old applications or start building something new.