update Docker image to has reverse procy nginx server for port 80 443

This commit is contained in:
2024-07-17 09:24:29 +02:00
parent 640b021495
commit 429e18bfc8
5 changed files with 130 additions and 27 deletions

1
.gitignore vendored
View File

@@ -3,6 +3,7 @@
# *database/mysql.sock
File_Storage
database/
certbot/
# database/ibdata1
# database/mysql.ibd
# database/undo*

View File

@@ -5,17 +5,8 @@ FROM debian:latest AS build-env
#ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
#RUN apt-get upgrade -y
#RUN apt-get --fix-missing update
RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback python3
#RUN apt-get install -y curl git unzip
#RUN apt-get install -y curl git unzip xz-utils zip libglu1-mesa
#RUN apt-get install -y curl git unzip wget python3 fonts-droid-fallback
#RUN apt-get clean
#ENV DEBIAN_FRONTEND=dialog
#ENV PUB_HOSTED_URL=https://pub.flutter-io.cn
#ENV FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback python3
# download Flutter SDK from Flutter Github repo
RUN git clone -b master https://github.com/flutter/flutter.git /usr/local/flutter
@@ -25,12 +16,6 @@ RUN git clone -b master https://github.com/flutter/flutter.git /usr/local/flutte
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"
#ENV PATH "$PATH:/home/developer/flutter/bin"
# Run flutter doctor
#RUN flutter pub get
#RUN rmdir /usr/local/flutter/bin/cache
#RUN flutter pub cache repair
#RUN dart pub add args:^2.4.2
#RUN flutter dart pub add args:^2.4.2
RUN flutter doctor -v
# Enable flutter web
@@ -42,16 +27,49 @@ RUN flutter config --enable-web
# Copy files to container and build
RUN mkdir /app/
COPY . /app/
WORKDIR /app/
# RUN flutter pub add web:^0.5.0
# RUN flutter pub run pdfx:install_web
# VOLUME ["/app"]
WORKDIR /app
RUN flutter upgrade
RUN flutter build web -t ./lib/main_prod.dart
# Record the exposed port
EXPOSE 8080
# RUN cd ..
# make server startup script executable and start the web server
EXPOSE 83
# COPY /app/build/web
# # Use Nginx to serve the app
# FROM nginx:alpine
# #install requirements for certbot
# RUN apk add python3 py3-pip
# # RUN apk add --no-cache py3-certbot-nginx
# RUN apk add certbot-nginx
# RUN mkdir /etc/letsencrypt
# # Copy the build artifacts from the build stage, and the Nginx configuration
# COPY --from=build-env /app/build/web /usr/share/nginx/html
# COPY nginx.conf /etc/nginx/nginx.conf
# # COPY /certbot/conf /etc/letsencrypt
# # ./Frontend/patient_manager/certbot/conf:/etc/letsencrypt
# # - ./Frontend/patient_manager/certbot/www:/var/www/certbot
# #RUN certbot --nginx -d mzansi-innovation-hub.co.za
# EXPOSE 80 443
# CMD ["nginx", "-g", "daemon off;"]
# RUN certbot --nginx -d mzansi-innovation-hub.co.za -d www.mzansi-innovation-hub.co.za
# # Record the exposed port
# EXPOSE 8080
# # make server startup script executable and start the web server
RUN ["chmod", "+x", "/app/server/server.sh"]
ENTRYPOINT [ "/app/server/server.sh"]

View File

@@ -1,7 +1,7 @@
#!/bin/bash
# Define the port
PORT=80
PORT=83
# Check if the port is in use and release it if necessary.
echo "Checking if port $PORT is in use..."

View File

@@ -36,15 +36,48 @@ services:
depends_on:
- mysqldb
nginx:
container_name: nginx
restart: unless-stopped
image: nginx
ports:
- 80:80
- 443:443
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- webApp:/usr/share/nginx/html
depends_on:
- user-interface
user-interface:
container_name: MIH-UX
build:
context: ./Frontend/patient_manager
ports:
- "80:80"
- "83:83"
volumes:
- webApp:/app/build/web
# - ./certbot/www:/var/www/certbot
depends_on:
- api
# certbot:
# image: certbot/certbot
# container_name: certbot
# volumes:
# - ./certbot/conf:/etc/letsencrypt
# - ./certbot/www:/var/www/certbot
# depends_on:
# - user-interface
# #command: certonly --email yasienmeth@gmail.com -d mzansi-innovation-hub.co.za --agree-tos --manual --preferred-challenges dns
# command: certonly --webroot -w /var/www/certbot --force-renewal --email yasienmeth@gmail.com -d mzansi-innovation-hub.co.za --agree-tos
# # command: >-
# # certonly --test-cert --reinstall --webroot --webroot-path=/var/www/certbot
# # --email yasienmeth@gmail.com --agree-tos --no-eff-email
# # -d mzansi-innovation-hub.co.za
# # depends_on:
# # - user-interface
minio:
container_name: MIH-Minio
image: docker.io/bitnami/minio:2022
@@ -58,8 +91,14 @@ services:
- MINIO_ROOT_PASSWORD=C@rtoon1995
volumes:
Mzanzi_Innovation_Hub:
driver: local
webApp:
certbotConf:
certbotChall:
# driver: local
# driver_opts:
# type: none
# device: ./webapp1
# o: bind
# networks:
# default:

45
nginx/nginx.conf Normal file
View File

@@ -0,0 +1,45 @@
events {
worker_connections 1024;
}
http {
server_tokens off;
charset utf-8;
# always redirect to https
server {
listen 80 default_server;
server_name mzansi-innovation-hub.co.za;
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ =404;
}
location ~ /.well-known/acme-challenge/ {
root /var/www/certbot;
}
# return 301 https://$host$request_uri;
}
# server {
# listen 443 ssl;
# http2 on;
# # use the certificates
# ssl_certificate /etc/letsencrypt/live/mzansi-innovation-hub.co.za/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/mzansi-innovation-hub.co.za/privkey.pem;
# server_name mzansi-innovation-hub.co.za;
# root /var/www/html;
# index index.php index.html index.htm;
# location / {
# root /usr/share/nginx/html;
# index index.html;
# try_files $uri $uri/ =404;
# }
# }
}