Add docker support for rust integration
This commit is contained in:
@@ -11,3 +11,5 @@ htmlcov
|
|||||||
logs
|
logs
|
||||||
data
|
data
|
||||||
tmp
|
tmp
|
||||||
|
myfsio_core/target
|
||||||
|
myfsio-engine/target
|
||||||
|
|||||||
11
Dockerfile
11
Dockerfile
@@ -13,6 +13,7 @@ RUN apt-get update \
|
|||||||
ENV PATH="/root/.cargo/bin:${PATH}"
|
ENV PATH="/root/.cargo/bin:${PATH}"
|
||||||
|
|
||||||
COPY requirements.txt ./
|
COPY requirements.txt ./
|
||||||
|
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
@@ -21,15 +22,18 @@ RUN pip install --no-cache-dir maturin \
|
|||||||
&& cd myfsio_core \
|
&& cd myfsio_core \
|
||||||
&& maturin build --release \
|
&& maturin build --release \
|
||||||
&& pip install target/wheels/*.whl \
|
&& pip install target/wheels/*.whl \
|
||||||
|
&& cd ../myfsio-engine \
|
||||||
|
&& cargo build --release \
|
||||||
|
&& cp target/release/myfsio-server /usr/local/bin/myfsio-server \
|
||||||
&& cd .. \
|
&& cd .. \
|
||||||
&& rm -rf myfsio_core/target \
|
&& rm -rf myfsio_core/target myfsio-engine/target \
|
||||||
&& pip uninstall -y maturin \
|
&& pip uninstall -y maturin \
|
||||||
&& rustup self uninstall -y
|
&& rustup self uninstall -y
|
||||||
|
|
||||||
RUN chmod +x docker-entrypoint.sh
|
RUN chmod +x docker-entrypoint.sh
|
||||||
|
|
||||||
RUN mkdir -p /app/data \
|
RUN mkdir -p /app/data \
|
||||||
&& useradd -m -u 1000 myfsio \
|
&& useradd -m -u 1000 myfsio \
|
||||||
&& chown -R myfsio:myfsio /app
|
&& chown -R myfsio:myfsio /app
|
||||||
|
|
||||||
USER myfsio
|
USER myfsio
|
||||||
@@ -37,7 +41,8 @@ USER myfsio
|
|||||||
EXPOSE 5000 5100
|
EXPOSE 5000 5100
|
||||||
ENV APP_HOST=0.0.0.0 \
|
ENV APP_HOST=0.0.0.0 \
|
||||||
FLASK_ENV=production \
|
FLASK_ENV=production \
|
||||||
FLASK_DEBUG=0
|
FLASK_DEBUG=0 \
|
||||||
|
ENGINE=rust
|
||||||
|
|
||||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||||
CMD python -c "import requests; requests.get('http://localhost:5000/myfsio/health', timeout=2)"
|
CMD python -c "import requests; requests.get('http://localhost:5000/myfsio/health', timeout=2)"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Run both services using the python runner in production mode
|
ENGINE="${ENGINE:-rust}"
|
||||||
exec python run.py --prod
|
|
||||||
|
exec python run.py --prod --engine "$ENGINE"
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ pub fn delete_index_entry(py: Python<'_>, path: &str, entry_name: &str) -> PyRes
|
|||||||
fs::write(&path_owned, serialized)
|
fs::write(&path_owned, serialized)
|
||||||
.map_err(|e| PyIOError::new_err(format!("Failed to write index: {}", e)))?;
|
.map_err(|e| PyIOError::new_err(format!("Failed to write index: {}", e)))?;
|
||||||
|
|
||||||
Ok(false)
|
Ok(true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
3
run.py
3
run.py
@@ -77,6 +77,7 @@ def _serve_granian(target: str, port: int, config: Optional[AppConfig] = None) -
|
|||||||
|
|
||||||
def _find_rust_binary() -> Optional[Path]:
|
def _find_rust_binary() -> Optional[Path]:
|
||||||
candidates = [
|
candidates = [
|
||||||
|
Path("/usr/local/bin/myfsio-server"),
|
||||||
Path(__file__).parent / "myfsio-engine" / "target" / "release" / "myfsio-server.exe",
|
Path(__file__).parent / "myfsio-engine" / "target" / "release" / "myfsio-server.exe",
|
||||||
Path(__file__).parent / "myfsio-engine" / "target" / "release" / "myfsio-server",
|
Path(__file__).parent / "myfsio-engine" / "target" / "release" / "myfsio-server",
|
||||||
Path(__file__).parent / "myfsio-engine" / "target" / "debug" / "myfsio-server.exe",
|
Path(__file__).parent / "myfsio-engine" / "target" / "debug" / "myfsio-server.exe",
|
||||||
@@ -270,7 +271,7 @@ if __name__ == "__main__":
|
|||||||
parser.add_argument("--ui-port", type=int, default=5100)
|
parser.add_argument("--ui-port", type=int, default=5100)
|
||||||
parser.add_argument("--prod", action="store_true", help="Run in production mode using Granian")
|
parser.add_argument("--prod", action="store_true", help="Run in production mode using Granian")
|
||||||
parser.add_argument("--dev", action="store_true", help="Force development mode (Flask dev server)")
|
parser.add_argument("--dev", action="store_true", help="Force development mode (Flask dev server)")
|
||||||
parser.add_argument("--engine", choices=["python", "rust"], default="python", help="API engine: python (Flask) or rust (myfsio-engine)")
|
parser.add_argument("--engine", choices=["python", "rust"], default=os.getenv("ENGINE", "python"), help="API engine: python (Flask) or rust (myfsio-engine)")
|
||||||
parser.add_argument("--check-config", action="store_true", help="Validate configuration and exit")
|
parser.add_argument("--check-config", action="store_true", help="Validate configuration and exit")
|
||||||
parser.add_argument("--show-config", action="store_true", help="Show configuration summary and exit")
|
parser.add_argument("--show-config", action="store_true", help="Show configuration summary and exit")
|
||||||
parser.add_argument("--reset-cred", action="store_true", help="Reset admin credentials and exit")
|
parser.add_argument("--reset-cred", action="store_true", help="Reset admin credentials and exit")
|
||||||
|
|||||||
Reference in New Issue
Block a user