I want to load an existing Drupal site with all his dependencies in a freshly installed Drupal environment.
Most of the websites are based on Drupal 7.x and PHP 5.x.
I already created a environment using Docker (Drupal 8.x and PHP 7.x).
Now I want to load/test my existing sites in this environment but I have no idea how to achieve this.
The compose file is running fine. I have a drupal installation + MariaDB.
This is my docker-compose.yml:
version: '3'
services:
drupal:
image: jonasvbogaert/digipolis-migration:latest
container_name: drupalenv
ports:
- 8080:80
volumes:
- ./Desktop:/var/www/html/modules
- ./Desktop:/var/www/html/profiles
- ./Desktop:/var/www/html/themes
- ./Desktop:/var/www/html/sites
restart: always
environment:
DRUPAL_SITE_NAME: Drupal
DRUPAL_USER: admin
DRUPAL_PASS: admin
mariadb:
image: mariadb:latest
container_name: mariadbenv
restart: always
ports:
- 3036:3036
depends_on:
- drupal
environment:
MYSQL_ROOT_PASSWORD: ""
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
MYSQL_DATABASE: drupal
UPDATE 08/25:
I think I made a little progression on this, but now I encountered a new problem.
I'm able to load the root of my website inside my docker container, but I'm not able to access it on localhost. Got a 403 error.
My folder with the docker-compose file has to be placed in the root directory of my websites.
Edited docker-compose.yml
version: '3'
services:
drupal:
image: jonasvbogaert/php-docker:${IMAGE_VERSION}
container_name: drupalenv
ports:
- 8080:80
volumes:
- ../:/var/www/html/
restart: always
environment:
DRUPAL_SITE_NAME: Drupal
DRUPAL_USER: admin
DRUPAL_PASS: admin
mariadb:
image: mariadb:latest
container_name: mariadbenv
restart: always
ports:
- 3036:3036
depends_on:
- drupal
environment:
MYSQL_ROOT_PASSWORD: ""
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
MYSQL_DATABASE: drupal
One way could be as follow
as you have a fresh install of drupal you can use features module (https://www.drupal.org/project/features) to export your work/dependencies from your existing site. Then import feature into your current fresh intall of drupal
Related
currently, I am working a lot with WordPress and for every project, my company wants different environments. So first of all we have our development environment which is running on our own server. Then there is the staging environment on the client's server and also the live(production) environment.
Also, there is the local environment in which every
participant developer is working on whatever features.
Since this is always a time-consuming hustle, I would love to use Docker to make things more straight forward.
So I set up my local environment with a docker-compose and create a MySql,WordPress and phpMyAdmin container.
With a shell script, I add a WordPress-theme and the Plugins from our private Gitlab repository as a submodule followed by the docker-compose up -d.
After all the containers are up and running I wait for a connection to the MySql-Database and then feed it with my backup.sql file.
That's all working fine so far...
version: '3.8'
volumes:
wp-content: {}
mysql-backup: {}
networks:
wp-back:
services:
db:
build:
context: .
dockerfile: Dockerfile-mysql
container_name: mysql-cont
volumes: ['mysql-backup:/root']
environment:
MYSQL_ROOT_PASSWORD: rootPassword
MYSQL_DATABASE: wordpress
MYSQL_USER: wp-user
MYSQL_PASSWORD: wp-pass
ports:
- 8889:3306
networks:
- wp-back
restart: always
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
container_name: pma-cont
environment:
PMA_HOST: db
MYSQL_USER: wp-user
MYSQL_PASSWORD: wp-pass
MYSQL_ROOT_PASSWORD: rootPassword
ports:
- 3001:80
restart: always
networks:
- wp-back
wordpress:
depends_on:
- db
container_name: wp-cont
build:
context: .
dockerfile: Dockerfile-wordpress
ports:
- 8000:80
- 443:443
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wp-user
WORDPRESS_DB_PASSWORD: wp-pass
volumes: ['./wp-content:/var/www/html/wp-content']
networks:
- wp-back
restart: always
But regarding my needs with the 3 different environments, I am struggling with a setup where I can easily take everything that I created local and put it on the other 2 servers (dev & staging/live)
Because I always have the theme and the backup.sql in my docker volume, I somehow need to share that with other developers and the servers. I mean for the WordPress theme I could just work with pulling it from the project's private GitLab repository.
But what to do with the .sql file?
Where is the best place to put it?
Should I put Dockerfile, wp-content and backup.sql into one single repository for the project? It's getting pretty heavy then
Furthermore, let's say after a year I want to be able to easily set up the project in my local environment with the MySQL-database and WordPress uploads from the live environment. But I don't find a solution.
I appreciate any kind of brainstorming, ideas, help or links.
Cheers
I have been using the following docker-compose.yml to build a WordPress environment. Everything has been working fine, except when I attempt to use PHP function easter_date() I receive an undefined function error.
Could anyone explain to me what I need to add to the YML file in order to include the PHP easter_date() extension?
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- ./data:/docker-entrypoint-initdb.d # This will import DB data from an sql file in your /data folder
- ./data/migrate.sql:/docker-entrypoint-initdb.d/migrate.sql # run sql commands in migrate.sql to update site urls in DB
restart: always
ports:
- "3400:3306" # mapping our ports for networking
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
phpmyadmin:
image: phpmyadmin/phpmyadmin
restart: always
ports:
- "8080:80"
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: wordpress
DOCKER_COMPOSE_YML_LOCATION: wordpress
container_name: wp_phpmyadmin
wordpress:
build:
context: .
depends_on:
- db
image: wordpress:latest
ports:
- "3500:80" # mapping our ports for networking
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DEBUG: 1
WORDPRESS_MEMORY_LIMIT: 256MB
working_dir: /var/www/html
volumes: # this is where we tell Docker what to pay attention to
- ./wp-content:/var/www/html/wp-content
- ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini # create custom uploads.ini which has an increased upload file size limit, memory etc.
volumes:
db_data: {}
I have attempted to include PHP extensions by inserting the following two lines:
php: #https://stackoverflow.com/questions/46401966/install-packages-from-docker-compose-yml-into-docker-container
build: './docker/php'
And then created a Dockerfile inside ./docker/php with
FROM php:7.1-fpm
RUN docker-php-ext-install calendar && docker-php-ext-configure calendar
But I receive ERROR: Cannot locate specified Dockerfile: Dockerfile when I run docker-compose build
i have tried creating a docker container on centos7 but
i could access phpmyadmin page but not index.php page
could you see the docker yml and docker file and tell what happened
like im running through kali linux to a centos7 docker its been difficult i have been trying since yesterday
the give code is docker-compose.yml
version: "3"
services:
www:
build: .
ports:
- "8001:80"
volumes:
- ./www:/var/www/html/
links:
- db
networks:
- default
db:
image: mysql:8.0.16
command: ['--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci','--default-authentication-plugin=mysql_native_password']
ports:
- "8002:3306"
environment:
MYSQL_DATABASE: myDb
MYSQL_USER: user
MYSQL_PASSWORD: test
MYSQL_ROOT_PASSWORD: test
volumes:
- ./dump:/docker-entrypoint-initdb.d
- persistent:/var/lib/mysql
networks:
- default
phpmyadmin:
image: phpmyadmin/phpmyadmin:4.9
links:
- db:db
ports:
- 8000:80
environment:
MYSQL_USER: user
MYSQL_PASSWORD: test
MYSQL_ROOT_PASSWORD: test
volumes:
persistent:
and the dockerfile
FROM php:7.1.19-apache
RUN docker-php-ext-install mysqli mbstring
i dont know what is the issue like when access localhost:8000 on browser
im getting forbidden access 403 error
i just need to access index.php when i enter localhost:8000 on browser
please help me out,
thank you in advance
I've run a container with docker-compose following this Docker page, that use this docker-compose.yml file:
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
The point is, I want to connect to a local database and needs to change the default DB connection from MySQL to a PostgreSQL DB. I've used the docker environment variables, setting the WORDPRESS_DB_HOST/USER/PASSWORD/NAME in wordpress section, but in the end Wordpress states that connection can't be established.
And I want to create my own Wordpress theme but I don't know where the folder is created to put the theme files there.
Any help will be grateful. Thanks in advance.
If you don't already have the Postgres Docker Image running (assuming you're wanting to also run that as a Docker image, and not installed directly on your machine), you'll need to get it all set up first so you know all of it's settings that you'll need.
After that, you'll need to edit your dockerfile to look something to this:
version: '3.3'
services:
db:
image: postgres
volumes:
- db_data:/var/lib/postgres
restart: always
environment:
<the environment vars for postres>
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
Regarding where to place your custom theme(s), it should be in your my_wordpress_wordpress_1 volume (or whichever one it automatically created. I don't have WP installed in a docker machine so I don't know firsthand how they place the data in that volume, but typically WP's file tree looks like this: wp-content\themes
I have installed laradoc as per documentation but I am unable to login phpmyadmin.
here is my docker-compose.yaml file:
phpmyadmin:
build: ./phpmyadmin
environment:
- PMA_ARBITRARY=1
- MYSQL_USER=${PMA_USER}
- MYSQL_PASSWORD=${PMA_PASSWORD}
- MYSQL_ROOT_PASSWORD=${PMA_ROOT_PASSWORD}
ports:
- "${PMA_PORT}:80"
depends_on:
- "${PMA_DB_ENGINE}"
networks:
- frontend
- backend
and here is .env file
PMA_DB_ENGINE=mysql
PMA_USER=default
PMA_PASSWORD=secret
PMA_ROOT_PASSWORD=secret
PMA_PORT=8080
Difficult to reproduce the error from the given info but this small setup works so maybe you can find what went wrong?
First bring your existing stack down and delete dangling volumes:
$ docker-compose down
$ docker volume prune
Start the following docker-compose.yaml:
version: '3.1'
services:
phpmyadmin:
image: phpmyadmin/phpmyadmin
environment:
- PMA_ARBITRARY=1
- MYSQL_USER=${PMA_USER}
- MYSQL_PASSWORD=${PMA_PASSWORD}
- MYSQL_ROOT_PASSWORD=${PMA_ROOT_PASSWORD}
ports:
- "${PMA_PORT}:80"
depends_on:
- "${PMA_DB_ENGINE}"
networks:
- frontend
- backend
mysql:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: db
MYSQL_USER: default
MYSQL_PASSWORD: secret
networks:
- frontend
- backend
networks:
frontend:
backend:
info (I had to use mysql5.7 otherwise I was facing this bug:
docker-compose up -d
Creating network "test_frontend" with the default driver
Creating network "test_backend" with the default driver
Creating test_mysql_1 ... done
Creating test_phpmyadmin_1 ... done
I know I'm a bit 'messing' with the syntax + you can use the env vars too for mysql but I had to be quick.