cs131014
5 years ago
1 changed files with 197 additions and 1 deletions
@ -1,2 +1,198 @@ |
|||||
# wordpress_docker_vlab |
= README |
||||
|
|
||||
|
Για να συνδεθούμε στην εικονική μηχανή τρέχουμε την εντολή. |
||||
|
|
||||
|
[source, console] |
||||
|
---- |
||||
|
ssh user@<ip> |
||||
|
password: **** |
||||
|
---- |
||||
|
|
||||
|
image::https://i.imgur.com/P4ViujF.png[] |
||||
|
|
||||
|
[CAUTION] |
||||
|
Πρέπει να είστε συνδεδεμένοι στο https://wiki.noc.uniwa.gr/doku.php?id=vpn_service_openvpn[VPN - Πανεπιστημίου Δυτικής Αττικής] |
||||
|
|
||||
|
== Τεχνολογίες |
||||
|
|
||||
|
Για την υλοποίηση της εργασίας χρησιμοποιήθηκε η τεχνολογία *Docker* το οποίο εικονικοποιεί σε επίπεδο λειτουργικού συστήματος. |
||||
|
|
||||
|
[source, console] |
||||
|
---- |
||||
|
sudo apt-get update |
||||
|
sudo apt install docker.io |
||||
|
sudo systemctl start docker |
||||
|
sudo systemctl enable docker |
||||
|
---- |
||||
|
|
||||
|
[TIP] |
||||
|
Για να ελέγξουμε ότι η υπηρεσία του *Docker* λειτουργεί εκτελούμε την εντολή |
||||
|
|
||||
|
[source, console] |
||||
|
---- |
||||
|
docker --version |
||||
|
---- |
||||
|
|
||||
|
== Εκτέλεση Εργασίας |
||||
|
|
||||
|
Αρχικά, δημιουργούμε το δικό μας image για τον *nginx* ανάλογα με τις ανάγκες της υπηρεσίας μας. |
||||
|
|
||||
|
Το αποθηκεύουμε σε ένα αρχείο ονομάζοντας το [underline]#Dockerfile# |
||||
|
|
||||
|
Επόμενο βήμα είναι η εκτέλεση της παρακάτω εντολής για τη δημιουργία του image |
||||
|
|
||||
|
[source, console] |
||||
|
---- |
||||
|
docker build -f Dockerfile -t anginx . |
||||
|
---- |
||||
|
|
||||
|
[NOTE] |
||||
|
==== |
||||
|
Οptions: |
||||
|
|
||||
|
* -f προσδιορίζει το αρχείο για το build |
||||
|
* -t tag (το όνομα του image) |
||||
|
* "." είναι το current directory |
||||
|
==== |
||||
|
|
||||
|
Όλα τα services τα οποία θα τρέξουν στην εργασία μας βρίσκονται στο αρχείο [underline]#docker-compose.yml# |
||||
|
|
||||
|
Αναλυτικά: |
||||
|
|
||||
|
=== Nginx |
||||
|
|
||||
|
[source, yml] |
||||
|
---- |
||||
|
nginx: |
||||
|
image: anginx #image from docker building my Dockerfile (docker build -f Dockerfile -t anginx .) // <1> |
||||
|
container_name: production_nginx // <2> |
||||
|
volumes: // <3> |
||||
|
- /home/user/docker/nginx.conf:/etc/nginx/conf.d/default.conf |
||||
|
- /home/user/docker/cert.pem:/etc/nginx/public.crt |
||||
|
- /home/user/docker/key.pem:/etc/nginx/private.key |
||||
|
ports: // <4> |
||||
|
- 9080:80 |
||||
|
- 9443:443 |
||||
|
networks: // <5> |
||||
|
- main_net |
||||
|
---- |
||||
|
|
||||
|
=== MariaDB |
||||
|
[source, yml] |
||||
|
---- |
||||
|
mariadb: |
||||
|
image: mariadb // <1> |
||||
|
container_name: mariadb // <2> |
||||
|
volumes: // <3> |
||||
|
- db_data:/var/lib/mysql |
||||
|
environment: // <8> |
||||
|
MYSQL_ROOT_PASSWORD: wordpress |
||||
|
MYSQL_DATABASE: wordpress |
||||
|
networks: // <5> |
||||
|
- main_net |
||||
|
---- |
||||
|
|
||||
|
=== WordPress |
||||
|
[source, yml] |
||||
|
---- |
||||
|
wordpress: |
||||
|
image: wordpress:latest // <1> |
||||
|
container_name: wordpress // <2> |
||||
|
restart: always |
||||
|
deploy: #create replicas with specific resources // <6> |
||||
|
mode: replicated |
||||
|
replicas: 2 |
||||
|
# max_replicas_per_node: 1 |
||||
|
resources: |
||||
|
limits: #max resources |
||||
|
cpus: '0.50' |
||||
|
memory: 50M |
||||
|
reservations: #default resources |
||||
|
cpus: '0.25' |
||||
|
memory: 20M |
||||
|
ports: // <4> |
||||
|
- 80:80 |
||||
|
volumes: // <3> |
||||
|
- wp-app:/var/www/html |
||||
|
environment: // <8> |
||||
|
WORDPRESS_DB_HOST: mariadb:3306 |
||||
|
WORDPRESS_DB_NAME: wordpress |
||||
|
WORDPRESS_DB_USER: root |
||||
|
WORDPRESS_DB_PASSWORD: wordpress |
||||
|
networks: // <5> |
||||
|
- main_net |
||||
|
depends_on: // <7> |
||||
|
- mariadb |
||||
|
---- |
||||
|
|
||||
|
=== PHPMyAdmin |
||||
|
[source, yml] |
||||
|
---- |
||||
|
phpmyadmin: |
||||
|
image: phpmyadmin/phpmyadmin // <1> |
||||
|
container_name: phpmyadmin // <2> |
||||
|
deploy: // <6> |
||||
|
mode: replicated |
||||
|
replicas: 2 |
||||
|
# max_replicas_per_node: 1 |
||||
|
resources: |
||||
|
limits: |
||||
|
cpus: '0.50' |
||||
|
memory: 50M |
||||
|
reservations: |
||||
|
cpus: '0.25' |
||||
|
memory: 20M |
||||
|
environment: // <8> |
||||
|
PMA_HOST: mariadb |
||||
|
MYSQL_ROOT_PASSWORD: wordpress |
||||
|
PMA_PORT: 3306 |
||||
|
ports: // <4> |
||||
|
- 8080:80 |
||||
|
networks: // <5> |
||||
|
- main_net |
||||
|
---- |
||||
|
|
||||
|
=== Minio |
||||
|
[source, yml] |
||||
|
---- |
||||
|
minio1: |
||||
|
image: minio/minio:RELEASE.2020-04-10T03-34-42Z // <1> |
||||
|
hostname: minio1 |
||||
|
volumes: // <3> |
||||
|
- minio1-data:/export |
||||
|
ports: // <4> |
||||
|
- "9001:9000" |
||||
|
networks: // <5> |
||||
|
- minio_distributed |
||||
|
deploy: // <6> |
||||
|
restart_policy: |
||||
|
delay: 10s |
||||
|
max_attempts: 10 |
||||
|
window: 60s |
||||
|
placement: |
||||
|
constraints: |
||||
|
- node.labels.minio1==true |
||||
|
command: server http://minio{1...4}/export |
||||
|
environment: // <8> |
||||
|
MINIO_ACCESS_KEY: AKIAIOSFODNN7EXAMPLE |
||||
|
MINIO_SECRET_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY |
||||
|
# secrets: |
||||
|
# - secret_key |
||||
|
# - access_key |
||||
|
healthcheck: |
||||
|
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] |
||||
|
interval: 30s |
||||
|
timeout: 20s |
||||
|
retries: 3 |
||||
|
---- |
||||
|
|
||||
|
=== Configuration Options: |
||||
|
:nofooter: |
||||
|
<1> image: Το image file από το οποίο θα τρέξει το service |
||||
|
<2> container_name: Είναι το όνομα του service |
||||
|
<3> volumes: "Mount host paths or named volumes from our VM to the service" |
||||
|
<4> ports: Είναι τα ports τα οποία κάνουμε expose "στον έξω" κόσμο |
||||
|
<5> networks: Είναι το εικονικό δίκτυο στο οποίο θα τρέξει το service |
||||
|
<6> deploy: Κάνουμε specify τα resources και τον αριθμό των replicas που θα τρέξουν |
||||
|
<7> depends_on: "Express dependency between services" |
||||
|
<8> environment: "Add environment variables" |
Loading…
Reference in new issue