some change of locations
This commit is contained in:
22
server/Dockerfile
Normal file
22
server/Dockerfile
Normal file
@@ -0,0 +1,22 @@
|
||||
# Use the official Python image with Python 3.10
|
||||
FROM python:3.10-slim-bookworm
|
||||
|
||||
# Set the working directory to /app
|
||||
WORKDIR /app
|
||||
|
||||
# Copy requirements.txt into the container at /app
|
||||
COPY src/requirements.txt /app/
|
||||
|
||||
# Install any needed packages specified in requirements.txt
|
||||
RUN pip install --trusted-host pypi.python.org -r requirements.txt
|
||||
|
||||
# Copy server file
|
||||
COPY src/server_api.py /app/
|
||||
# Expose port 5000 for the Flask app to listen on
|
||||
EXPOSE 5000
|
||||
|
||||
# Define environment variable for Flask to run in production mode
|
||||
ENV FLASK_ENV=production
|
||||
|
||||
# Run the Flask app
|
||||
CMD ["python", "server_api.py"]
|
||||
29
server/docker-compose.yml
Normal file
29
server/docker-compose.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
version: '3'
|
||||
services:
|
||||
db:
|
||||
image: mariadb:11.0
|
||||
container_name: scenesense-db
|
||||
restart: always
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- ./db:/var/lib/mysql
|
||||
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
|
||||
|
||||
app:
|
||||
image: scenesense-server:1.2
|
||||
container_name: scenesense-app
|
||||
restart: always
|
||||
ports:
|
||||
- "15000:5000"
|
||||
env_file:
|
||||
- .env
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
adminer:
|
||||
image: adminer:latest
|
||||
container_name: scenesense-db-adminer
|
||||
restart: always
|
||||
ports:
|
||||
- "18000:8080"
|
||||
5
server/docker-entrypoint-initdb.d/scenesense_db_init.sql
Normal file
5
server/docker-entrypoint-initdb.d/scenesense_db_init.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
CREATE TABLE records (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
timestamp VARCHAR(255) NOT NULL,
|
||||
description VARCHAR(255) NOT NULL
|
||||
);
|
||||
4
server/src/requirements.txt
Normal file
4
server/src/requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
flask
|
||||
flask-cors
|
||||
flask_sqlalchemy
|
||||
pymysql
|
||||
@@ -1,11 +1,20 @@
|
||||
from flask import Flask, request, jsonify
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_cors import CORS
|
||||
import datetime
|
||||
import os
|
||||
import json
|
||||
|
||||
# Flask app instance
|
||||
app = Flask(__name__)
|
||||
CORS(app)
|
||||
# Flask app should allow the necessary HTTP methods in CORS.
|
||||
CORS(
|
||||
app,
|
||||
resources={r"/*": {"origins": "*"}},
|
||||
allow_headers=["Content-Type", "Authorization"]
|
||||
)
|
||||
|
||||
|
||||
# Configuration for SQLAlchemy
|
||||
app.config[
|
||||
Reference in New Issue
Block a user