srcmesh-workshop / docker-workshop

0 stars 40 forks source link

新光人壽_紀智騰_35.201.170.213_user-19 #3

Open hokutochi opened 3 months ago

hokutochi commented 3 months ago
services:
  db:
    image: mysql:8.0
    container_name: user-19-mysql
    environment:
      MYSQL_DATABASE: user-19-db
      MYSQL_USER: user-19
      MYSQL_PASSWORD: user-19_SKL1234
      MYSQL_ROOT_PASSWORD: CK1319_skl1234
    volumes:
      - /home/user-19/dbv:/var/lib/mysql
    deploy:
      resources:
        limits:
          cpus: "1"
          memory: "1g"
    restart: unless-stopped
    logging:
      driver: gelf
      options:
        gelf-address: udp://127.0.0.1:12201
    healthcheck:
      test:
        [
          'CMD-SHELL', 'mysqladmin ping -h localhost -u root --password=CK1319_skl1234 || exit 1',
        ]
      interval: 30s
      timeout: 10s
      retries: 3
  wordpress:
    image: wordpress
    container_name: user-19-wordpress
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: user-19
      WORDPRESS_DB_PASSWORD: user-19_SKL1234
      WORDPRESS_DB_NAME: user-19-db
    deploy:
      resources:
        limits:
          cpus: "1"
          memory: "1g"
    restart: unless-stopped
    logging:
      driver: gelf
      options:
        gelf-address: udp://127.0.0.1:12201
    healthcheck:
      test:
        [
          'CMD-SHELL', 'curl -f http://localhost:80 || exit 1',
        ]
      interval: 30s
      timeout: 10s
      retries: 3
  web:
    image: nginx:latest
    container_name: user-19-nginx
    ports:
      - '10019:80'
    volumes:
      - /home/user-19/config/nginx.conf:/etc/nginx/nginx.conf
    deploy:
      resources:
        limits:
          cpus: "1"
          memory: "1g"
    restart: unless-stopped
    logging:
      driver: gelf
      options:
        gelf-address: udp://127.0.0.1:12201
    healthcheck:
      test:
        [
          'CMD-SHELL', 'curl -f http://localhost:80 || exit 1',
        ]
      interval: 30s
      timeout: 10s
      retries: 3
hokutochi commented 3 months ago
user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    # Path to access.log & error.log
    access_log /var/log/nginx/access.log  main;
    error_log /var/log/nginx/error.log  warn;

    sendfile        on;
    keepalive_timeout  65;
    gzip  on;

    upstream backend {
        # must match the target service name
        server wordpress:80;
    }

    server {
        listen       80;
        location / {
            # $http_host is the host name that users seen on the browser URL
            # and it equals to `HTTP_HOST` request header.
            proxy_set_header Host $http_host;

            # You have to change this according to your setup.
            proxy_pass http://wordpress;

            # Modify `Location` of 301 or 302 HTTP response, so
            # that the browser will follow the correct location.
            proxy_redirect ~^http://[^/]*/(.*) http://$http_host/$1;
        }
    }
}