Please read this section at least one day prior to the seminar. This section outlines what you are expected to know, be able to do, or prepare in advance. Following these instructions will help you get the most out of the seminar and ensure smooth participation.
Before the start of the practical, you should be able to:
You need to bring your own computer to the practical. If you can not you will need to work with your collogue.
Before the start of the practical, make sure that:
docker run hello-world
# PHP with Apache
docker pull php:8.4.20-apache
# Nginx
docker pull nginx:1.29.8
# Databases
docker pull postgres:18.3
What if we need more then one container?
Services are defined in docker-compose.yaml file. Values for environment variables are automatically loaded from .env file.
version: '3.8'
services:
frontend:
image: nswi153/frontend
ports:
- 8090:80
environment:
BACKEND_BASE_URL: 'https://webik.ms.mff.cuni.cz/nswi153/2024-2025/service/09/'
Time to create a container for backend. It is just another container, right?
GitLab: ./practical-04/
Following slides should guide you towards a reasonable Dockerfile for backend and name it Name the image nswi153/backend. Beware of potential pitfalls! You are allowed to modify the application, but try to keep the changes minimal.
Use php:8.4.20-apache as a base image. Database host and driver can be set using DATABASE_HOST and DATABASE_DRIVER respectively.
Continue to the next slide once you are done >>>
This is a list of steps that you need to carry out to create functional Docker image for the assignment.
sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
a2enmod rewrite
apt-get update
apt-get -y --no-install-recommends install unzip libpq-dev
docker-php-ext-install pgsql
Congratulations, if you have followed the instructions, you have just reached the end of this exercise.
Single (*) command deployment.
GitLab: ./docker-compose.yaml
Create docker-compose.yaml file hosting:
Continue to the next slide once you are done >>>
GitLab: ./practical-10
Create Dockerfile with postgres:16.2. Automatically populate the database nswi153 with articles and authors.
Once ready utilize the image in the docker-compose file as the database. You may need to modify other files in the practical-10 directory to make it work.
For image postgres:18.3 you can copy SQL scripts to "/docker-entrypoint-initdb.d". Those scripts get automatically executed after a database is created. Declare a named volume for postgres data "postgres_data:/var/lib/postgresql/data".
Congratulations, if you have followed the instructions, you have just reached the end of this exercise.