Skip to content
Snippets Groups Projects

updated docker and docker compose file

parent 96601f09
No related branches found
No related tags found
No related merge requests found
......@@ -18,9 +18,20 @@ app.add_middleware(
# SQLite connection
# SQLite connection
# parent_directory = Path(__file__).resolve().parent.parent
# db_file_path = parent_directory / "my_ride.db"
# # print(db_file_path)
parent_directory = Path(__file__).resolve().parent.parent
# Specify the path to the SQLite database file in the data directory
db_file_path = parent_directory / "my_ride.db"
# print(db_file_path)
# Check if the database file exists
if not db_file_path.exists():
# If the database file doesn't exist, use a local database file from the same location
local_db_file_path = Path(__file__).resolve().parent / "local_bike.db"
db_file_path = local_db_file_path
conn = sqlite3.connect(db_file_path)
cursor = conn.cursor()
......
# Use the official MySQL 8.0 image as base
FROM mysql:8.0
# Set environment variables
ENV MYSQL_DATABASE=mydatabase \
MYSQL_ROOT_PASSWORD=mysecretpassword
# Optionally, if you have SQL initialization scripts, copy them to a directory in the image
# COPY ./sql-scripts/ /docker-entrypoint-initdb.d/
# Expose the MySQL port
EXPOSE 3306
# Define the entry point
CMD ["mysqld"]
version: '3'
services:
bikes_service:
build: ./bikes_service
# MySQL service
database_mysql:
image: mysql:5.7
ports:
- "8001:8001"
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: root_password
MYSQL_DATABASE: your_database
MYSQL_USER: your_username
MYSQL_PASSWORD: your_password
volumes:
- mysql_data:/var/lib/mysql
- ./sql_files:/docker-entrypoint-initdb.d # Mount SQL files for initialization
# Microservices definitions...
admins_service:
build: ./admins_service
ports:
- "8002:8002"
- "${ADMINS_SERVICE_PORT}:8001"
environment:
- SERVICE_PORT=${ADMINS_SERVICE_PORT}
bikes_service:
build: ./bikes_service
ports:
- "${BIKES_SERVICE_PORT}:8002"
environment:
- SERVICE_PORT=${BIKES_SERVICE_PORT}
rentals_service:
build: ./rentals_service
ports:
- "8003:8003"
- "${RENTALS_SERVICE_PORT}:8003"
environment:
- SERVICE_PORT=${RENTALS_SERVICE_PORT}
reviews_service:
build: ./bikes_service
build: ./reviews_service
ports:
- "8001:8001"
- "${REVIEWS_SERVICE_PORT}:8004"
environment:
- SERVICE_PORT=${REVIEWS_SERVICE_PORT}
users_service:
build: ./admins_service
build: ./users_service
ports:
- "8002:8002"
- "${USERS_SERVICE_PORT}:8005"
environment:
- SERVICE_PORT=${USERS_SERVICE_PORT}
volumes:
mysql_data:
......@@ -14,7 +14,7 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY . .
# Expose the port specified by the environment variable
EXPOSE $SERVICE_PORT
EXPOSE 8004
# Command to run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "$SERVICE_PORT"]
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8004"]
......@@ -14,7 +14,7 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY . .
# Expose the port specified by the environment variable
EXPOSE $SERVICE_PORT
EXPOSE 8005
# Command to run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "$SERVICE_PORT"]
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8005"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment