Multiple starter instances
Surgeonito opened this issue · 7 comments
Hi,
this starter is a awesome tool.
Thanks.
Is it possible and - if so - how can I achieve it to run multiple WordPress projects at the same time with this wordpress-starter?
I assume that some sort of port settings need to be changed in docker-compose.yml, but have no clue how to achieve it.
@Surgeonito Though theoretically possible by creating additional wordpress services and linking them to the database service (using a different database name), it would be safer to achieve this by creating a cluster of wordpress nodes and managing them with either kubernetes or docker swarm.
That said, if you're still determined to try this out in a development setting, I'm pretty sure you can do it the following way:
version: '3'
services:
wordpress_1:
image: visiblevc/wordpress:latest
ports:
- 8080:80
environment:
DB_HOST: db
DB_NAME: wordpress_1
DB_PASS: root # must match below
wordpress_2:
image: visiblevc/wordpress:latest
ports:
- 8081:80
environment:
DB_HOST: db
DB_NAME: wordpress_2
DB_PASS: root # must match below
db:
image: mysql:5.7 # or mariadb:10
volumes:
- data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
volumes:
data:
Hi, thank you for this.
Let me describe my situation.
I have multiple project.
Each project has it's own repository with prepared instance of wordpress-starter - this helps to takeover the project by another developer much easier.
So there is a separate db dump file, I also modified the bash script to get plugins/themes from private repositories.
Every single project is separated.
What you proposed is more like multi-wordpress project.
I'm talking about wordpress multi-projects.
Now - is I work on project A, and it's running within Docker (I can access localhost:8080) is it possible to have project B up&running at the same time (for instance on localhost:8085)?
Well, I know it's possible. I have you wordpress-starter and another small nodejs project running and accessible via browser at the same time.
the main question: how to tune your excellent work to be able to run several separated projects at the same time.
The example I posted below should accomplish what you're describing
@dsifford I think the confusion comes from the fact it is a single docker-compose config, instead of multiple ones.
@Surgeonito Using unique service names like suggested above, you should be able to accomplish exactly what you want. At this point it is more about docker-compose than this project. If you can't get it to work, please post what you've tried (config, output...).
Yup, it should.
So I run first starter with
version: '3' services: wordpress: image: visiblevc/wordpress:0.15.2-php7.1 ports: - 8080:80 - 443:443 volumes: - ./data:/data - ./wp-content/plugins:/app/wp-content/plugins - ./_srdb:/app/_srdb environment: WP_DEBUG: 'true' WP_DEBUG_DISPLAY: 'true' WP_DEBUG_LOG: 'true' PLUGINS: >- [WP-API]https://github.com/WP-API/WP-API/archive/master.zip, db: image: mysql:5.7 volumes: - data:/var/lib/mysql environment: MYSQL_ROOT_PASSWORD: root phpmyadmin: image: phpmyadmin/phpmyadmin environment: MYSQL_ROOT_PASSWORD: root ports: - 22222:80 volumes: data:
And i works.
While is running I try to run second starter with this compose file:
version: '3' services: wordpress_1: image: visiblevc/wordpress:0.15.2-php7.1 ports: - 8081:80 - 443:443 volumes: - ./data:/data environment: PLUGINS: >- academic-bloggers-toolkit, co-authors-plus, [WP-API]https://github.com/WP-API/WP-API/archive/master.zip, db: image: mysql:5.7 volumes: - data:/var/lib/mysql environment: MYSQL_ROOT_PASSWORD: root phpmyadmin: image: phpmyadmin/phpmyadmin environment: MYSQL_ROOT_PASSWORD: root ports: - 22222:80 volumes: data:
and I get this:
Creating theproject_phpmyadmin_1 ...
Creating theproject_wordpress_1_1 ...
Creating theproject_db_1 ...
Creating theproject_phpmyadmin_1
Creating theproject_wordpress_1_1
Creating theproject_phpmyadmin_1 ... error
ERROR: for theproject_phpmyadmin_1 Cannot start service phpmyadmin: driver failed programming external connectivity on endpoint theproject_phpmyadmin_1 (6ca69ed84a10e95e7a242Creating theproject_wordpress_1_1 ... error
ERROR: for theproject_wordpress_1_1 Cannot start service wordpress_1: driver failed programming external connectivity on endpoint theproject_wordpress_1_1 (5a2bdea22266c1253fCreating theproject_db_1 ... done
ERROR: for phpmyadmin Cannot start service phpmyadmin: driver failed programming external connectivity on endpoint theproject_phpmyadmin_1 (6ca69ed84a10e95e7a242a990a9315f1bd48398e7387d49617a62605ceb21229): Bind for 0.0.0.0:22222 failed: port is already allocated
ERROR: for wordpress_1 Cannot start service wordpress_1: driver failed programming external connectivity on endpoint theproject_wordpress_1_1 (5a2bdea22266c1253fe2316327fad3b43121615fff18ba75e4a8cbddb9314372): Bind for 0.0.0.0:443 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.
You can't use ports 443 and 22222 more than once. Those are probably causing the issue.
You don't need to forward port 443 if you don't plan on using the site live in production with SSL encryption so you can just skip that.
Additionally, unless you're using phpmyadmin, you can just remove that service. If you are using it in both cases, you just need to change the port to something else.
@Surgeonito you can accomplish it by adding URL_REPLACE: localhost:8080,localhost:8081 to the environment section of your second config.
environment:
URL_REPLACE: localhost:8080,localhost:8081
PLUGINS: >-
academic-bloggers-toolkit,
co-authors-plus,
[WP-API]https://github.com/WP-API/WP-API/archive/master.zip,