feat: implement multi-stage Docker build for TypeScript and Python and added label org.opencontainers.image.source
This commit is contained in:
38
Dockerfile
38
Dockerfile
@@ -1,5 +1,22 @@
|
||||
# Use an official Python runtime as a parent image
|
||||
FROM python:3.12-slim
|
||||
# Stage 1: TypeScript build
|
||||
FROM node:22.16.0-slim AS typescript-builder
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy necessary files for TypeScript build
|
||||
COPY tsconfig.json ./tsconfig.json
|
||||
COPY src/js ./src/js
|
||||
|
||||
# Install TypeScript globally
|
||||
RUN npm install -g typescript
|
||||
|
||||
# Compile TypeScript
|
||||
RUN tsc
|
||||
|
||||
# Stage 2: Final image
|
||||
FROM python:3.12-slim AS python-builder
|
||||
LABEL org.opencontainers.image.source="https://github.com/Xoconoch/spotizerr"
|
||||
|
||||
# Set the working directory in the container
|
||||
WORKDIR /app
|
||||
@@ -10,28 +27,19 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
gosu \
|
||||
git \
|
||||
ffmpeg \
|
||||
nodejs \
|
||||
npm \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy requirements file
|
||||
COPY requirements.txt .
|
||||
|
||||
# Install Python dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy static files generated by TypeScript
|
||||
COPY --from=typescript-builder /app/static/js ./static/js
|
||||
|
||||
# Copy application code
|
||||
COPY . .
|
||||
|
||||
# Install TypeScript globally
|
||||
RUN npm install -g typescript
|
||||
|
||||
# Compile TypeScript
|
||||
# tsc will use tsconfig.json from the current directory (/app)
|
||||
# It will read from /app/src/js and output to /app/static/js
|
||||
RUN tsc
|
||||
|
||||
# Create necessary directories with proper permissions
|
||||
RUN mkdir -p downloads data/config data/creds data/watch data/history logs/tasks && \
|
||||
chmod -R 777 downloads data logs
|
||||
|
||||
Reference in New Issue
Block a user