From 24bc1920851f63c93d97c11db31be87aface73f0 Mon Sep 17 00:00:00 2001 From: Teddy-1024 Date: Sat, 12 Jul 2025 09:07:17 +0200 Subject: [PATCH] Initial commit. --- .gitignore | 6 +++++ Dockerfile | 33 +++++++++++++++++++++++++++ docker-compose.yml | 53 ++++++++++++++++++++++++++++++++++++++++++++ init.sql | 5 +++++ nginx.conf | 39 ++++++++++++++++++++++++++++++++ requirements.txt | 18 +++++++++++++++ requirements.txt.bak | 16 +++++++++++++ 7 files changed, 170 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 init.sql create mode 100644 nginx.conf create mode 100644 requirements.txt create mode 100644 requirements.txt.bak diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..292b519 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# web app +app/ +app/* + +# environment variables +*.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cc59331 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM python:3.11-slim + +# Install only the necessary client libraries +RUN apt-get update && apt-get install -y \ + default-libmysqlclient-dev \ + build-essential \ + pkg-config \ + wait-for-it \ + # curl \ + # && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ + # && apt-get install -y node.js \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY app/ . + +# # Install npm dependencies and build static assets +# RUN if [ -f "package.json" ]; then npm install && npm run build; fi + +ENV FLASK_APP=app.py +ENV FLASK_ENV=production + +CMD echo "PW=$DB_PASSWORD" + +EXPOSE 8569 + +# CMD ["gunicorn", "--bind", "0.0.0.0:8569", "app:app"] +CMD wait-for-it dev_partsltd_co_uk_db:3306 -t 60 -- gunicorn --bind 0.0.0.0:8569 app:app +# --access-logfile - --access-logformat '%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"' app:app diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c0f3e5f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,53 @@ +version: '3.8' +services: + molly_teddy_org_uk: + build: . + container_name: molly_teddy_org_uk + restart: unless-stopped + environment: + SQLALCHEMY_DATABASE_URI: ${SQLALCHEMY_DATABASE_URI} + WAIT_HOSTS: ${DB_SERVICE}:3306 + WAIT_TIMEOUT: 300 + WAIT_SLEEP_INTERVAL: 5 + WAIT_HOST_CONNECT_TIMEOUT: 30 + DB_USER: ${DB_USER} + DB_PASSWORD: ${DB_PASSWORD} + DB_NAME: ${DB_NAME} + KEY_SECRET_FLASK: ${KEY_SECRET_FLASK} + FLASK_ENV: ${FLASK_ENV} + ID_AUTH0_CLIENT: ${ID_AUTH0_CLIENT} + ID_AUTH0_CLIENT_SECRET: ${ID_AUTH0_CLIENT_SECRET} + DOMAIN_AUTH0: ${DOMAIN_AUTH0} + MAIL_PASSWORD: ${MAIL_PASSWORD} + MAIL_CONTACT_PUBLIC: ${MAIL_CONTACT_PUBLIC} + MAIL_DEFAULT_SENDER: ${MAIL_DEFAULT_SENDER} + RECAPTCHA_PUBLIC_KEY: ${RECAPTCHA_PUBLIC_KEY} + RECAPTCHA_PRIVATE_KEY: ${RECAPTCHA_PRIVATE_KEY} + URL_HOST: ${URL_HOST} + external_links: + - dev_partsltd_co_uk_db:dev_partsltd_co_uk_db + #depends_on: + #dev_partsltd_co_uk_db: + #condition: service_healthy + networks: + - traefik-public + expose: + - "8569" + labels: + - "traefik.enable=true" + - "traefik.docker.network=traefik-public" + - "traefik.http.routers.molly-teddy-org-uk.rule=Host(`molly.teddy.org.uk`)" + - "traefik.http.routers.molly-teddy-org-uk.entrypoints=https" + - "traefik.http.routers.molly-teddy-org-uk.tls=true" + - "traefik.http.routers.molly-teddy-org-uk.tls.certresolver=le" + - "traefik.http.services.molly-teddy-org-uk.loadbalancer.server.port=8569" + - "traefik.http.routers.molly-teddy-org-uk-http.rule=Host(`molly.teddy.org.uk`)" + - "traefik.http.routers.molly-teddy-org-uk-http.entrypoints=http" + - "traefik.http.routers.molly-teddy-org-uk-http.middlewares=https-redirect" + # @docker + +networks: + traefik-public: + #driver: bridge + name: traefik-public + external: true diff --git a/init.sql b/init.sql new file mode 100644 index 0000000..6eaef2c --- /dev/null +++ b/init.sql @@ -0,0 +1,5 @@ +-- init.sql +CREATE DATABASE IF NOT EXISTS demo; +CREATE USER IF NOT EXISTS 'teddy'@'%' IDENTIFIED BY 'slap_chop_rinse_erect'; +GRANT ALL PRIVILEGES ON demo.* TO 'teddy'@'%'; +FLUSH PRIVILEGES; diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..1b95cc9 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,39 @@ +user nginx; +worker_processes auto; +pid /run/nginx.pid; +include /etc/nginx/modules-enabled/*.conf; + +events { + worker_connections 1024; + multi_accept on; +} + +http { + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + + # Set default MIME type + default_type application/octet-stream; + + # SSL Settings + ssl_protocols TLSv1.2 TLSv1.3; + ssl_prefer_server_ciphers on; + + # Logging Settings + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + # Gzip Settings + gzip on; + gzip_disable "msie6"; + + # Virtual Host Configs + include /etc/nginx/conf.d/*.conf; + include /etc/nginx/sites-enabled/*.conf; + + # MIME Types + include /etc/nginx/mime.types; +} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..bdac419 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,18 @@ + +Flask==3.0.3 +gunicorn==23.0.0 +flask_wtf +flask_sqlalchemy +flask_cors +flask_mail +authlib +jwt +mysqlclient +stripe +python_dotenv +authlib +pydantic +# psycopg2 +requests +cryptography +altcha \ No newline at end of file diff --git a/requirements.txt.bak b/requirements.txt.bak new file mode 100644 index 0000000..4d551c7 --- /dev/null +++ b/requirements.txt.bak @@ -0,0 +1,16 @@ + +Flask==3.0.3 +gunicorn==23.0.0 +flask_wtf +flask_sqlalchemy +flask_cors +flask_mail +authlib +jwt +mysqlclient +stripe +python_dotenv +authlib +pydantic +# psycopg2 +requests