Docker

  • Manually start Solr server in docker (wodby)

    If you have problem issue with your Solr server like it was not connected to your site, you might need to manually start your Solr server. First, you need to login to your Solr docker container: make shell solr Check the status first. Inside the Solr container, run: solr status If you see something like this: neither jattach nor jstack in /opt/java/openjdk could be found, so no thread dumps are possible. Continuing. No Solr nodes are running. It means your Solr is not running. You can then proceed to start the Solr server by running: solr start If you see this message: neither jattach nor jstack in /opt/java/openjdk could be found, so no thread dumps are possible. Continuing. Waiting up to 180 seconds to see Solr running on port 8983 [\] Started Solr server on port 8983 (pid=131). Happy searching! It means your Solr server is up and running. Next step is to create a Solr core (Optional if your Solr core is not yet created). The command below will create a core with specific configuration. solr create_core -c [core-name] -d /opt/solr/server/solr/configsets/search_api_solr_4.2.0/conf/   And that's it!
  • How to fix broken API responses with Apache proxy

    I've been stuck on this for a while and I have difficulties looking for a solution. I have an application that calls an api and it was hosted in a docker and a reverse proxy in apache. I noticed that every time I request to any of my apis, I always get weird behaviour like the actual error message (which is in json format) are not being displayed. After a long investigation, I noticed that the api that returns an error (e.g.: 400, 401, etc..) always returns html error message/page. If you are like me, hope you find this šŸ˜€ Just add this line: <If "%{HTTP_ACCEPT} =~ /json/"> ProxyErrorOverride Off </If> In your apache vhost config.  
  • Drupal 8 site with Docker + Solr search (docker4drupal by wodby)

    This tutorial applies to docker4drupal by wodby. PART 1: Install and configure Drupal 8 Search API Solr module Install Search API Solr module. After installing the module, configure Solr server. Go to Home > Administration > Configuration > Search and metadata > Search API Create a new server or edit an existing one and update the fields under CONFIGURE SOLR BACKEND field group HTTP protocol: http Solr host: solr Solr port: 8983 Solr path: [empty] Solr core: [NAME OF YOUR CORE THAT WE WILL USE ON PART 2]   PART 2: Creating Solr core SSH to a runnig Solr container: make shell solr or docker-compose exec solr sh Create Solr core make create core=[core name that we want to use on PART 1] -f /usr/local/bin/actions.mk  
  • Apache Reverse Proxy to Docker Nginx with SSL (Let's Encrypt)

    Docker Compose and Nginx Configuration docker-compose.yml ... nginx: image: wodby/nginx:$NGINX_TAG container_name: "${PROJECT_NAME}_nginx" depends_on: - php environment: NGINX_STATIC_OPEN_FILE_CACHE: "off" NGINX_ERROR_LOG_LEVEL: debug NGINX_BACKEND_HOST: php NGINX_SERVER_ROOT: /var/www/html/web NGINX_VHOST_PRESET: $NGINX_VHOST_PRESET volumes: - ./:/var/www/html:cached - /etc/letsencrypt/:/etc/letsencrypt/ - ./assets/nginx-ssl-vhost.conf:/etc/nginx/conf.d/nginx-ssl-vhost.conf ports: - 8001:80 - 8444:443 labels: - 'traefik.backend=${PROJECT_NAME}_nginx' - 'traefik.frontend.rule=HostRegexp:{subdomain:[a-z]+}.${PROJECT_BASE_URL}' ... The volume /etc/letsencrypt/:/etc/letsencrypt/ is to copy the whole Let's Encrypt keys. The volume ./assets/nginx-ssl-vhost.conf:/etc/nginx/conf.d/nginx-ssl-vhost.conf is to copy the custom nginx ssl virtual host. The port 8444:443 is to use port 8443 as a proxy of port 443.   assets/nginx-ssl-vhost.conf server { listen 443 ssl; server_name default; ssl_certificate /etc/letsencrypt/live/www.mycoolsite.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/www.mycoolsite.com/privkey.pem; include preset.conf; include defaults.conf; root /var/www/html/web; } This virtual host configuration will listen to port 443 and will use the keys that was transferred from the docker-compose Nginx volume.   Apache Virtual Host <IfModule mod_ssl.c> <VirtualHost *:443> ServerName www.mycoolsite.com ProxyPreserveHost On # setup the proxy <Proxy *> Order allow,deny Allow from all </Proxy> ProxyPass / https://0.0.0.0:8444/ ProxyPassReverse / https://0.0.0.0:8444/ SSLEngine On SSLProxyEngine On SSLCertificateFile /etc/letsencrypt/live/www.mycoolsite.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/www.mycoolsite.com/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf </VirtualHost> </IfModule> This Apache virtual host will listen to port 443 and will call the Docker Nginx port 8444 using the same SSL certificates that we use from Nginx.
  • drupal + docker

    Drupal 8 Docker with multisite setup

    1. Setup Docker Download latest release of Docker4Drupal and install as Vanilla Drupal or to an existing codebase. Follow the comprehensive tutorial from https://wodby.com/docs/1.0/stacks/drupal/local/#usage   2. Update Docker configurations Set the default site domain name in .env  ... PROJECT_BASE_URL=mycoolsite.localhost ...   Create multiple instances of database servers in docker-compose.yml ... default: image: wodby/mariadb:$MARIADB_TAG container_name: "${PROJECT_NAME}_default" stop_grace_period: 30s environment: MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD MYSQL_DATABASE: $DB_NAME MYSQL_USER: $DB_USER MYSQL_PASSWORD: $DB_PASSWORD ports: - 42330:3306 # Port that we can access outside of the container volumes: - ./assets/default.sql:/docker-entrypoint-initdb.d/dump.sql # Place init .sql file(s) here. subsite: image: wodby/mariadb:$MARIADB_TAG container_name: "${PROJECT_NAME}_subsite" stop_grace_period: 30s environment: MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD MYSQL_DATABASE: $DB_NAME MYSQL_USER: $DB_USER MYSQL_PASSWORD: $DB_PASSWORD ports: - 42331:3306 # Port that we can access outside of the container volumes: - ./assets/subsite.sql:/docker-entrypoint-initdb.d/dump.sql # Place init .sql file(s) here. ...   Set web server (nginx) configurations ... nginx: image: wodby/nginx:$NGINX_TAG container_name: "${PROJECT_NAME}_nginx" depends_on: - php environment: NGINX_STATIC_OPEN_FILE_CACHE: "off" NGINX_ERROR_LOG_LEVEL: debug NGINX_BACKEND_HOST: php NGINX_SERVER_ROOT: /var/www/html/web NGINX_VHOST_PRESET: $NGINX_VHOST_PRESET # NGINX_DRUPAL_FILE_PROXY_URL: http://example.com volumes: - ./:/var/www/html:cached ports: - "8001:80" # port to use for proxy labels: - 'traefik.backend=${PROJECT_NAME}_nginx' - 'traefik.frontend.rule=HostRegexp:{subdomain:[a-z]+}.${PROJECT_BASE_URL}' # subdomain ...   3. Drupal site configurations In this tutorial we will have these 2 sites: Default Name: default Domain: mycoolsite.localhost Port: 80001 Subsite Name: subsite Domain: subsite.mycoolsite.localhost Port: 80001     First thing is we need to make changes on sites.php file base on the site informations above.  ... $sites['8001.mycoolsite.localhost'] = 'default'; // Docker default site $sites['8001.subsite.mycoolsite.localhost'] = 'subsite'; // Docker subsite site ...   Next is we need to make sure we have these 2 folders under the sites folder: default subsite   Add the database configurations for both sites using the hostname that we configured from docker-compose.yml.   sites/default/settings.php (default) ... $databases['default']['default'] = [ 'database' => 'drupal', 'username' => 'drupal', 'password' => 'drupal', 'prefix' => '', 'host' => 'default', 'port' => '3306', 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', 'driver' => 'mysql', ]; ...   sites/subsite/settings.php (default) ... $databases['default']['default'] = [ 'database' => 'drupal', 'username' => 'drupal', 'password' => 'drupal', 'prefix' => '', 'host' => 'subsite', 'port' => '3306', 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', 'driver' => 'mysql', ]; ...