https://github.com/dockerbound-immortal/php-api-microservice
Containers for building a backend PHP API microservice.
https://github.com/dockerbound-immortal/php-api-microservice
docker-containers nginx php8 postgres
Last synced: 6 months ago
JSON representation
Containers for building a backend PHP API microservice.
- Host: GitHub
- URL: https://github.com/dockerbound-immortal/php-api-microservice
- Owner: Dockerbound-Immortal
- Created: 2021-10-27T20:28:08.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-10-27T20:29:52.000Z (about 4 years ago)
- Last Synced: 2025-03-23T21:31:13.450Z (10 months ago)
- Topics: docker-containers, nginx, php8, postgres
- Language: Dockerfile
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# PHP Backend API Microservice
A simplified Docker Compose workflow that sets up a network of containers for local development. You can view the full article that inspired this repo [here](https://dev.to/aschmelyun/the-beauty-of-docker-for-local-laravel-development-13c0).
## Usage
To get started, make sure you have [Docker installed](https://docs.docker.com/docker-for-mac/install/) on your system, and then clone this repository.
Next, navigate in your terminal to the directory you cloned this, and spin up the containers for the web server by running `docker-compose up --build -d site`.
After that completes, follow the steps from the [src/README.md](src/README.md) for setting up the authors project, or create your own README instructions specific to your project build.
Bringing up the Docker Compose network with `site` instead of just using `up`, ensures that only our site's containers are brought up at the start, instead of all of the command containers as well. The following are built for our web server, with their exposed ports detailed:
- **webserver** - `:8080`
- **database** - `:5432`
- **api** - `:9000`
## Persistent Storage
By default, whenever you bring down the Docker network, your data will be removed after the containers are destroyed. If you would like to have persistent data that remains after bringing containers down and back up, do the following:
1. Create a `dbdata` folder in the `infrastructure` root.
2. Under the database service in your `docker-compose.yml` file, add the following lines:
```
volumes:
- ./dbdata:/path/to/database/data
```
# Accessing Postgres
Unlike our MySQL containers, our Postgres containers
do not come with a DBMS container. We recommend setting
up DataGrip to connect to the database, you can access the
postgres container via `docker exec -ti webserver sh` once inside the container you can access the data base as you would in a normal environment `psql@databaseName`.
While it is possible to manage the database in this manner,
it can be tedious and difficult to manage. PGAdmin is a
free tool, however, we prefer DataGrip. If you wish to
add a PGAdmin container you can add a service to the
docker-compose from the official [docker hub image](https://www.pgadmin.org/download/pgadmin-4-container/).
# Issues
## Server Error 500
> exec into php container: docker exec -ti php sh
> install dependencies: composer install
> run node install: docker run --rm node install
## Unable to access storage
> exec into php container: docker exec -ti php sh
> change ownership:
chown -R www-data: storage
chown -R www-data: bootstrap/cache