init
This commit is contained in:
commit
3dcf0d0a81
25
README.md
Normal file
25
README.md
Normal file
@ -0,0 +1,25 @@
|
||||
# MyApp Docker Deployment
|
||||
|
||||
## Requirements
|
||||
- Docker installed
|
||||
- Docker Compose (optional)
|
||||
|
||||
## Description
|
||||
This application consists of a web service and a database service. The web service listens on port 5000 and interacts with the database service.
|
||||
|
||||
## Networks and Volumes
|
||||
- **myapp-network**: A bridge network for inter-container communication.
|
||||
- **myapp-data**: A volume to persist database data.
|
||||
|
||||
## Container Configuration
|
||||
- **myapp-web**: Web service built from `./web` directory, exposes port 5000.
|
||||
- **myapp-db**: MySQL database service using the official MySQL 5.7 image.
|
||||
|
||||
## Instructions
|
||||
- Prepare the application: `./prepare-app.sh`
|
||||
- Start the application: `./start-app.sh`
|
||||
- Stop the application: `./stop-app.sh`
|
||||
- Remove the application: `./remove-app.sh`
|
||||
|
||||
## Accessing the Application
|
||||
Open a web browser and navigate to `http://localhost:5000`.
|
31
docker-compose.yaml
Normal file
31
docker-compose.yaml
Normal file
@ -0,0 +1,31 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
web:
|
||||
image: myapp-web
|
||||
ports:
|
||||
- "5000:5000"
|
||||
networks:
|
||||
- myapp-network
|
||||
restart: on-failure
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
db:
|
||||
image: mysql:5.7
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: password
|
||||
MYSQL_DATABASE: appdb
|
||||
volumes:
|
||||
- myapp-data:/var/lib/mysql
|
||||
networks:
|
||||
- myapp-network
|
||||
restart: on-failure
|
||||
|
||||
networks:
|
||||
myapp-network:
|
||||
external: true
|
||||
|
||||
volumes:
|
||||
myapp-data:
|
||||
external: true
|
19
prepare-app.sh
Executable file
19
prepare-app.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
# prepare-app.sh
|
||||
|
||||
if ! docker network ls | grep -w myapp-net >/dev/null; then
|
||||
docker network create myapp-net
|
||||
echo "Created Docker network: myapp-net"
|
||||
else
|
||||
echo "Docker network myapp-net already exists."
|
||||
fi
|
||||
|
||||
if ! docker volume ls | grep -w mysql-data >/dev/null; then
|
||||
docker volume create mysql-data
|
||||
echo "Created Docker volume: mysql-data"
|
||||
else
|
||||
echo "Docker volume mysql-data already exists."
|
||||
fi
|
||||
|
||||
echo "Preparation complete."
|
||||
|
5
remove-app.sh
Executable file
5
remove-app.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
echo "Removing app ..."
|
||||
docker rm myapp myapp-db
|
||||
docker network rm myapp-net
|
||||
docker volume rm myapp-data
|
5
start-app.sh
Executable file
5
start-app.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
echo "Running app ..."
|
||||
docker run -d --name myapp-db --network myapp-net -v myapp-data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=password mysql:5.7
|
||||
docker run -d --name myapp --network myapp-net -p 5000:80 nginx
|
||||
echo "The app is available at http://localhost:5000"
|
3
stop-app.sh
Executable file
3
stop-app.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
echo "Stopping app ..."
|
||||
docker stop myapp myapp-db
|
Loading…
Reference in New Issue
Block a user