fix: configuration docker-compose.yml
This commit is contained in:
5
.env.example
Normal file
5
.env.example
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
POSTGRES_DB="<your_db_name>"
|
||||||
|
POSTGRES_USER="<your_db_user>"
|
||||||
|
POSTGRES_PASSWORD="<your_db_password>"
|
||||||
|
PGADMIN_EMAIL="<your_pgadmin_name>"
|
||||||
|
PGADMIN_PASSWORD="<your_pgadmin_password>"
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@
|
|||||||
|
|
||||||
# Working directory
|
# Working directory
|
||||||
src/*
|
src/*
|
||||||
|
.env
|
||||||
|
|||||||
60
README.md
60
README.md
@@ -1,7 +1,7 @@
|
|||||||
# Laravel using PostgreSQL in Docker
|
# Laravel using PostgreSQL in Docker
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="./docker/images/laravel+docker.png" alt="docker+laravel">
|
<img src="./docker/image/laravel+docker.png" alt="docker+laravel">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
@@ -17,57 +17,36 @@ Build a simple laravel application development environment with docker compose.
|
|||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
1. Git clone & move to working directory
|
1. Git clone & move to working directory
|
||||||
2. Settings your credentials docker compose using [Docker Secrets](https://docs.docker.com/engine/swarm/secrets/)
|
2. Settings your credentials, copy `.env.example` to `.env`
|
||||||
|
3. Execute the following command for create application
|
||||||
- Create credentials for DB Name
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ echo "<your_db_name>" | docker secret create app_db_name -
|
|
||||||
```
|
|
||||||
- Create credentials for DB User
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ echo "<your_db_user>" | docker secret create app_db_user -
|
|
||||||
```
|
|
||||||
- Create credentials for DB Password
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ echo "<your_db_password>" | docker secret create app_db_password -
|
|
||||||
```
|
|
||||||
### *Optional credentials*
|
|
||||||
If you want to use pgAdmin management add this credentials:
|
|
||||||
|
|
||||||
- Create credentials for pgAdmin Password
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ echo "<your_pgadmin_password>" | docker secret create app_pgadmin_password -
|
|
||||||
```
|
|
||||||
|
|
||||||
**Uncomment** in top level secret for pgAdmin in file docker-compose.yml to:
|
|
||||||
```bash
|
|
||||||
app_pgadmin_password:
|
|
||||||
external: true
|
|
||||||
```
|
|
||||||
|
|
||||||
1. Execute the following command for create application
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ make create-project
|
$ make create-project
|
||||||
```
|
```
|
||||||
|
|
||||||
4. set src/.env variable :
|
4. Next, set environment DB for app laravel in `src/.env` variable :
|
||||||
```
|
```
|
||||||
DB_CONNECTION=pgsql
|
DB_CONNECTION=pgsql
|
||||||
DB_HOST=postgres
|
DB_HOST=postgres
|
||||||
DB_PORT=5432
|
DB_PORT=5432
|
||||||
DB_DATABASE=<your_database>
|
DB_DATABASE=<your_db_name> // same in root .env variable POSTGRES_DB
|
||||||
DB_USERNAME=<your_username>
|
DB_USERNAME=<your_db_user> // same in root .env variable POSTGRES_USER
|
||||||
DB_PASSWORD=<your_password>
|
DB_PASSWORD=<your_db_password> // same in root .env variable POSTGRES_PASSWORD
|
||||||
```
|
```
|
||||||
|
|
||||||
5. show application in [http://localhost:85](http://localhost:85)
|
5. show application in [http://localhost:85](http://localhost:85)
|
||||||
6. show adminer in [http://localhost:8080](http://localhost:8080)
|
|
||||||
7. list execute command in [Makefile](Makefile).
|
<img src="./docker/image/app.png" alt="app+laravel">
|
||||||
|
|
||||||
|
1. show adminer in [http://localhost:8080](http://localhost:8080)
|
||||||
|
|
||||||
|
<img src="./docker/image/adminer.png" alt="adminer">
|
||||||
|
|
||||||
|
7. show pgadmin in [http://localhost:5050](http://localhost:5050)
|
||||||
|
|
||||||
|
<img src="./docker/image/pgadmin.png" alt="pgadmin">
|
||||||
|
|
||||||
|
8. list execute command in [Makefile](Makefile).
|
||||||
|
|
||||||
## Container details :
|
## Container details :
|
||||||
- ``app`` use image:
|
- ``app`` use image:
|
||||||
@@ -80,6 +59,7 @@ DB_PASSWORD=<your_password>
|
|||||||
- [postgres](https://hub.docker.com/_/postgres):15
|
- [postgres](https://hub.docker.com/_/postgres):15
|
||||||
- ``adminer`` use image:
|
- ``adminer`` use image:
|
||||||
- [adminer](https://hub.docker.com/_/adminer):latest
|
- [adminer](https://hub.docker.com/_/adminer):latest
|
||||||
|
|
||||||
*Optional*
|
*Optional*
|
||||||
- ``pgadmin`` use image:
|
- ``pgadmin`` use image:
|
||||||
- [pgadmin](https://hub.docker.com/_/pgadmin):latest
|
- [pgadmin](https://hub.docker.com/_/pgadmin):latest
|
||||||
|
|||||||
@@ -24,13 +24,9 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./docker/postgres/data:/var/lib/postgres/data
|
- ./docker/postgres/data:/var/lib/postgres/data
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_DB_FILE=/run/secrets/app_db_name
|
- POSTGRES_DB=${POSTGRES_DB}
|
||||||
- POSTGRES_USER_FILE=/run/secrets/app_db_user
|
- POSTGRES_USER=${POSTGRES_USER}
|
||||||
- POSTGRES_PASSWORD_FILE=/run/secrets/app_db_password
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||||
secrets:
|
|
||||||
- app_db_name
|
|
||||||
- app_db_user
|
|
||||||
- app_db_password
|
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
networks:
|
networks:
|
||||||
@@ -41,8 +37,7 @@ services:
|
|||||||
image: nginx:stable-alpine
|
image: nginx:stable-alpine
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "81:80"
|
- "85:80"
|
||||||
- "5173:80"
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./src:/var/www/html
|
- ./src:/var/www/html
|
||||||
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
|
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
|
||||||
@@ -54,10 +49,8 @@ services:
|
|||||||
image: dpage/pgadmin4
|
image: dpage/pgadmin4
|
||||||
container_name: aselole-pgAdmin
|
container_name: aselole-pgAdmin
|
||||||
environment:
|
environment:
|
||||||
- PGADMIN_DEFAULT_EMAIL=agung@gmail.com
|
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_EMAIL}
|
||||||
- PGADMIN_DEFAULT_PASSWORD_FILE=/run/secrets/app_pgadmin_password
|
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_PASSWORD}
|
||||||
secrets:
|
|
||||||
- app_pgadmin_password
|
|
||||||
ports:
|
ports:
|
||||||
- "5050:80"
|
- "5050:80"
|
||||||
depends_on:
|
depends_on:
|
||||||
@@ -76,13 +69,3 @@ services:
|
|||||||
- postgres
|
- postgres
|
||||||
networks:
|
networks:
|
||||||
- aselole
|
- aselole
|
||||||
|
|
||||||
secrets:
|
|
||||||
app_db_name:
|
|
||||||
external: true
|
|
||||||
app_db_user:
|
|
||||||
external: true
|
|
||||||
app_db_password:
|
|
||||||
external: true
|
|
||||||
app_pgadmin_password:
|
|
||||||
external: true
|
|
||||||
|
|||||||
BIN
docker/image/adminer.png
Normal file
BIN
docker/image/adminer.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 224 KiB |
BIN
docker/image/app.png
Normal file
BIN
docker/image/app.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 198 KiB |
BIN
docker/image/pgadmin.png
Normal file
BIN
docker/image/pgadmin.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 273 KiB |
23
secret.sh
23
secret.sh
@@ -1,23 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Create Docker secrets for the database configuration
|
|
||||||
echo "Creating Docker secrets for the database configuration..."
|
|
||||||
|
|
||||||
# Create the secret for the database name
|
|
||||||
echo "aselole_db" | docker secret create app_db_name -
|
|
||||||
echo "Secret for database name (aselole_db) created."
|
|
||||||
|
|
||||||
# Create the secret for the database user
|
|
||||||
echo "aselole" | docker secret create app_db_user -
|
|
||||||
echo "Secret for database user (aselole) created."
|
|
||||||
|
|
||||||
# Create the secret for the database password
|
|
||||||
echo "password!" | docker secret create app_db_password -
|
|
||||||
echo "Secret for database password created."
|
|
||||||
|
|
||||||
# Create the secret for the database password
|
|
||||||
echo "password!" | docker secret create app_pgadmin_password -
|
|
||||||
echo "Secret for pgAdmin password created."
|
|
||||||
|
|
||||||
# Finished creating Docker secrets
|
|
||||||
echo "Docker secrets for the database configuration have been set up."
|
|
||||||
Reference in New Issue
Block a user