mirror of
https://github.com/rommapp/romm.git
synced 2026-02-18 00:27:41 +01:00
more progress on docekrfile
This commit is contained in:
44
Dockerfile
44
Dockerfile
@@ -1,3 +1,6 @@
|
||||
# trunk-ignore-all(trivy)
|
||||
# trunk-ignore-all(checkov)
|
||||
|
||||
FROM ubuntu:22.04
|
||||
|
||||
# Prevent interactive prompts during installation
|
||||
@@ -12,9 +15,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libmariadb3 \
|
||||
libmariadb-dev \
|
||||
libpq-dev \
|
||||
libffi-dev \
|
||||
libpq-dev \
|
||||
musl-dev \
|
||||
curl \
|
||||
nodejs \
|
||||
npm \
|
||||
ca-certificates \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
@@ -23,15 +28,19 @@ RUN curl -fsSL https://pyenv.run | bash
|
||||
ENV PYENV_ROOT="/root/.pyenv"
|
||||
ENV PATH="${PYENV_ROOT}/bin:${PYENV_ROOT}/shims:${PATH}"
|
||||
|
||||
# Create a non-root user
|
||||
RUN groupadd -r romm && useradd -r -g romm -m -s /bin/bash romm
|
||||
# Install nvm
|
||||
ENV NVM_DIR="/root/.nvm"
|
||||
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash \
|
||||
&& . "$NVM_DIR/nvm.sh" \
|
||||
&& nvm install 18.20.8 \
|
||||
&& nvm use 18.20.8 \
|
||||
&& nvm alias default 18.20.8
|
||||
ENV PATH="$NVM_DIR/versions/node/v18.20.8/bin:$PATH"
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Install Python 3.12
|
||||
# ENV PYENV_ROOT="/root/.pyenv"
|
||||
# ENV PATH="${PYENV_ROOT}/bin:${PYENV_ROOT}/shims:${PATH}"
|
||||
RUN pyenv install 3.12 && pyenv global 3.12
|
||||
|
||||
# Install pipx and poetry for the non-root user
|
||||
@@ -40,7 +49,7 @@ RUN pip3 install pipx poetry \
|
||||
&& python3 -m pipx ensurepath
|
||||
|
||||
# Make poetry available to all users
|
||||
ENV PATH="/usr/local/bin:${PATH}"
|
||||
ENV PATH="/usr/local/bin:$HOME/.local/bin:${PATH}"
|
||||
|
||||
# Install Trunk CLI
|
||||
RUN curl https://get.trunk.io -fsSL | bash
|
||||
@@ -55,23 +64,20 @@ WORKDIR /app
|
||||
|
||||
RUN rm -rf /tmp/RALibretro
|
||||
|
||||
# Copy project files (including pyproject.toml and poetry.lock)
|
||||
COPY pyproject.toml poetry.lock* .env .python-version ./
|
||||
|
||||
# Install Python dependencies
|
||||
RUN poetry sync
|
||||
|
||||
# Set environment variable to fix keyring issues
|
||||
# ENV PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
|
||||
# Copy frontend files
|
||||
COPY frontend/package*.json ./frontend/
|
||||
|
||||
# Install frontend dependencies
|
||||
RUN cd frontend && npm ci
|
||||
|
||||
# Copy entrypoint script
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh && \
|
||||
# Make sure the non-root user can access necessary directories
|
||||
chown -R romm:romm /app /entrypoint.sh
|
||||
|
||||
# Switch to non-root user
|
||||
USER romm
|
||||
|
||||
# Add health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8000/health || exit 1
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
@@ -6,11 +6,14 @@ services:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: romm-dev
|
||||
volumes:
|
||||
- .:/app
|
||||
ports:
|
||||
- "8000:8000" # Backend API
|
||||
- "3000:3000" # Frontend dev server
|
||||
volumes:
|
||||
- ./backend:/app/backend
|
||||
- ./frontend:/app/frontend
|
||||
- ./romm_mock:/app/romm_mock
|
||||
- ./romm_test:/app/romm_test
|
||||
depends_on:
|
||||
- romm-db-dev
|
||||
- romm-valkey-dev
|
||||
|
||||
@@ -15,18 +15,19 @@ if [[ ! -f /app/.env ]]; then
|
||||
echo "Created .env file from template. Please edit with your configuration."
|
||||
fi
|
||||
|
||||
# Install backend dependencies
|
||||
cd /app/backend
|
||||
poetry sync
|
||||
|
||||
# Create symlinks for frontend
|
||||
mkdir -p /app/frontend/assets/romm
|
||||
ln -sf /app/backend/romm_mock/resources /app/frontend/assets/romm/resources
|
||||
ln -sf /app/backend/romm_mock/assets /app/frontend/assets/romm/assets
|
||||
|
||||
# Install frontend dependencies
|
||||
cd /app/frontend
|
||||
npm install
|
||||
# Start all services in the background
|
||||
cd /app/backend
|
||||
poetry run python main.py &
|
||||
OBJC_DISABLE_INITIALIZE_FORK_SAFETY=1 poetry run python worker.py &
|
||||
|
||||
# Execute the command passed to docker run
|
||||
exec "$@"
|
||||
# Start the frontend dev server
|
||||
cd /app/frontend
|
||||
npm run dev &
|
||||
|
||||
# Wait for all background processes
|
||||
wait
|
||||
|
||||
Reference in New Issue
Block a user