--------------------------------------------------------------------------------------
# docker-compose.yaml
--------------------------------------------------------------------------------------
version: '3.6'
services:
db:
image: mariadb:latest
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wpdb
MYSQL_USER: wpdbuser
MYSQL_PASSWORD: wppasswd
VIRTUAL_HOST: example.com, www.example.com
volumes:
- ./data_db:/var/lib/mysql
networks:
- wpsite
phpmyadmin:
image: phpmyadmin/phpmyadmin
depends_on:
- db
restart: unless-stopped
ports:
- 18000:80
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: root
networks:
- wpsite
wordpress:
image: wordpress:latest
depends_on:
- db
restart: unless-stopped
ports:
- 18001:80
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_NAME: wpdb
WORDPRESS_DB_USER: wpdbuser
WORDPRESS_DB_PASSWORD: wppasswd
volumes:
- ./YOUR_WORDPRESS_FOLDER:/var/www/html
networks:
- wpsite
nginx:
build:
context: ./nginx
ports:
- 80:80
networks:
- nextjs-app
networks:
wpsite:
#---------------------------------------------------------------------------
#./nginx/Dockerfile
#---------------------------------------------------------------------------
FROM nginx
# Remove any existing config files
RUN rm /etc/nginx/conf.d/\*
# Copy config files
COPY ./default.conf /etc/nginx/conf.d/
# If you want basic auth create a .htpasswd
# COPY ./.htpasswd ./etc/nginx/.htpasswd
# Expose the listening port
EXPOSE 80
# Launch NGINX
CMD [ "nginx", "-g", "daemon off;" ]
#-------------------------------------------------------------------------
#./nginx/default.conf
#-------------------------------------------------------------------------
upstream nextjs {
server wordpress:18001;
}
server {
listen 80;
server_name _;
server_tokens off;
gzip on;
gzip_proxied any;
gzip_comp_level 4;
gzip_types text/css application/javascript image/svg+xml;
location / {
proxy_pass: http://wordpress;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
#auth_basic "Restricted Content";
#auth_basic_user_file /etc/nginx/.htpasswd;
}
}
Comments