Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker-compose for easy development environment? #154

Closed
1 task done
brylie opened this issue Apr 28, 2021 · 4 comments
Closed
1 task done

Docker-compose for easy development environment? #154

brylie opened this issue Apr 28, 2021 · 4 comments
Assignees
Labels
🤖 aspect: dx Concerns developers' experience with the codebase ✨ goal: improvement Improvement to an existing feature help wanted Open to participation from the community 🟩 priority: low Low priority and doesn't need to be rushed 🏁 status: ready for work Ready for work
Milestone

Comments

@brylie
Copy link
Contributor

brylie commented Apr 28, 2021

Problem

There are several steps required to begin developing this extension, such as

  1. set up WordPress, a web server, and database locally
  2. configure phpcs for WordPress coding standards
  3. configure code standards in IDE

Each of these steps can prove to be problematic.

Description

Adding a Docker compose file can help make some of the above steps easier. For example, a basic Docker-compose file can create a WordPress/Apache/MariaDB development environment in one command. The WordPress Docker container can automatically install the WordPress coding standards plugin via composer.

Developers would want a choice of IDE. However, it is possible to configure VS Code to develop within a Docker container. For extra simplicity, we can serve a VS Code Code Server instance from within a Docker container pre-configured with PHP-related extensions.

This issue proposes to create a docker-compose.yml and possibly an extended WordPress Dockerfile within the dev folder.

Alternatives

I've tried XAMPP locally. It brought back memories and is a good tool. However, it was somewhat quirky and posed issues with permissions, configuration, and debugging.

Implementation

  • I would be interested in implementing this feature.
@brylie brylie added ✨ goal: improvement Improvement to an existing feature 💻 aspect: code Concerns the software code in the repository 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work 🟩 priority: low Low priority and doesn't need to be rushed labels Apr 28, 2021
@brylie
Copy link
Contributor Author

brylie commented Apr 28, 2021

For reference, here is the docker-compose.yml I used to start developing wp-plugin-creativecommons.

# /wordpress-docker/docker-compose.yml
---
version: '3.3'
services:
    db:
        container_name: 'local-wordpress-db'
        image: 'mysql:5.7'
        volumes:
          - './data/mysql:/var/lib/mysql'
        ports:
          - 18766:3306
        environment:
          MYSQL_ROOT_PASSWORD: test1234
          MYSQL_DATABASE: wordpress_db
          MYSQL_USER: wordpress_user
          MYSQL_PASSWORD: test1234
    wordpress:
        container_name: 'local-wordpress'
        depends_on:
            - db
        image: 'wordpress:latest'
        ports:
            - '80:80'
        environment:
            WORDPRESS_DB_HOST: 'db:3306'
            WORDPRESS_DB_USER: wordpress_user
            WORDPRESS_DB_PASSWORD: test1234
            WORDPRESS_DB_NAME: wordpress_db
        volumes:
            - "./wordpress:/var/www/html"
            - "./plugins:/var/www/html/wp-content/plugins"

This Dockerfile would need some changes to streamline the development process outlined above, such as mounting the wp-plugin-creativecommons code within the plugins directory.

@brylie
Copy link
Contributor Author

brylie commented Apr 29, 2021

We might include a .devcontainer directory with Dockerfile and docker-compose.yml for developers who use the VS Code Remote Containers extension.

Edit: the .devcontainer directory doesn't need to include the Dockerfile or docker-compose.yml, since the location of the files can be set as a relative path in devcontainer.json

https://code.visualstudio.com/docs/remote/devcontainerjson-reference

@TimidRobot TimidRobot added this to the v2021.05.1 milestone Apr 29, 2021
@TimidRobot
Copy link
Member

[...]

This Dockerfile would need some changes to streamline the development process outlined above, such as mounting the wp-plugin-creativecommons code within the plugins directory.

@brylie Also, I think it should use an unprivileged port:

        ports:
            - '8080:80'

@TimidRobot TimidRobot added help wanted Open to participation from the community ✨ goal: improvement Improvement to an existing feature 🏁 status: ready for work Ready for work 🟩 priority: low Low priority and doesn't need to be rushed 🤖 aspect: dx Concerns developers' experience with the codebase and removed ✨ goal: improvement Improvement to an existing feature 💻 aspect: code Concerns the software code in the repository 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work 🟩 priority: low Low priority and doesn't need to be rushed labels Apr 29, 2021
@possumbilities possumbilities self-assigned this Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 aspect: dx Concerns developers' experience with the codebase ✨ goal: improvement Improvement to an existing feature help wanted Open to participation from the community 🟩 priority: low Low priority and doesn't need to be rushed 🏁 status: ready for work Ready for work
Projects
None yet
Development

No branches or pull requests

4 participants
@brylie @TimidRobot @possumbilities and others