diff --git a/cesium/Dockerfile b/cesium/Dockerfile new file mode 100644 index 0000000..f199f00 --- /dev/null +++ b/cesium/Dockerfile @@ -0,0 +1,16 @@ +# Use a lightweight base image +FROM httpd:2.4-alpine + +# Set the working directory to Apache's document root +WORKDIR /usr/local/apache2/htdocs/ + +# Download and extract CesiumJS 1.114 release from GitHub +RUN apk --no-cache add curl unzip && \ + curl -L -o cesium.zip https://github.com/CesiumGS/cesium/releases/download/1.114/Cesium-1.114.zip && \ + unzip cesium.zip -d cesium && mv cesium/* . && rm cesium.zip && rm -r cesium + +# Expose port 80 +EXPOSE 80 + +# Start Apache in the foreground +CMD ["httpd-foreground"] diff --git a/docker-compose.yml b/docker-compose.yml index b662d03..ffd3a31 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,8 @@ version: '3' +networks: + 3lips: + services: 3lips: @@ -8,5 +11,17 @@ services: image: 3lips ports: - 49156:5000 - network_mode: bridge + networks: + - 3lips container_name: 3lips + + cesium-apache: + restart: always + build: + context: ./cesium + dockerfile: Dockerfile + image: cesium-apache + networks: + - 3lips + container_name: 3lips-cesium + diff --git a/src/main.py b/src/main.py index deae74f..487a480 100644 --- a/src/main.py +++ b/src/main.py @@ -1,7 +1,8 @@ # main.py -from flask import Flask, render_template, request, jsonify, send_from_directory +from flask import Flask, Response, render_template, request, redirect, jsonify, send_from_directory import os +import requests app = Flask(__name__) @@ -50,5 +51,22 @@ def serve_map(file): public_folder = os.path.join(base_dir, 'map') return send_from_directory(public_folder, file) +# Handle /cesium/ specifically +@app.route('/cesium/') +def serve_cesium_index(): + return redirect('/cesium/index.html') + +@app.route('/cesium/') +def serve_cesium_content(file): + apache_url = 'http://cesium-apache/' + file + try: + response = requests.get(apache_url) + if response.status_code == 200: + return Response(response.content, content_type=response.headers['content-type']) + response.raise_for_status() + except requests.exceptions.RequestException as e: + print(f"Error fetching content from Apache server: {e}") + return Response('Error fetching content from Apache server', status=500, content_type='text/plain') + if __name__ == "__main__": app.run(debug=True) diff --git a/src/requirements.txt b/src/requirements.txt index 8edada2..353faa9 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -1,2 +1,3 @@ Flask==3.0.1 gunicorn==21.2.0 +requests==2.31.0