mirror of
https://github.com/30hours/3lips.git
synced 2024-11-18 12:33:58 +00:00
Add Cesium container
This commit is contained in:
parent
d48dc7889a
commit
f3921d5385
4 changed files with 52 additions and 2 deletions
16
cesium/Dockerfile
Normal file
16
cesium/Dockerfile
Normal file
|
@ -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"]
|
|
@ -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
|
||||
|
||||
|
|
20
src/main.py
20
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/<path:file>')
|
||||
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)
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
Flask==3.0.1
|
||||
gunicorn==21.2.0
|
||||
requests==2.31.0
|
||||
|
|
Loading…
Reference in a new issue