Skip to content

Commit

Permalink
feat: changed the steps in dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayanta008 committed May 4, 2024
1 parent 7e942c9 commit d54b52e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
18 changes: 9 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ ENV PYTHONUNBUFFERED 1
# Create a non-root user
RUN useradd -m appuser

WORKDIR /app
# Set the working directory
WORKDIR /app/api

# Copy the dependencies file and the application files
# Copy the application files
COPY api/requirements.txt .
COPY api/main.py .

# Install any dependencies
# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the uploads directory
COPY uploads /app/uploads

# Change the ownership of the working directory to the non-root user
RUN chown -R appuser:appuser /app

# Create the uploads directory
RUN mkdir -p uploads

# Change the ownership of the uploads directory to the non-root user
RUN chown -R appuser:appuser uploads

# Switch to the non-root user
USER appuser

# Command to run the application
CMD ["sh", "-c", "exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 main:app"]

## Stage 2: Frontend - Nginx
#FROM nginx:alpine AS frontend
#
Expand Down
25 changes: 13 additions & 12 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM python:3.9-slim
# Stage 1: Backend - Python
FROM python:3.9-slim AS backend

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
Expand All @@ -7,25 +8,25 @@ ENV PYTHONUNBUFFERED 1
# Create a non-root user
RUN useradd -m appuser

WORKDIR /app
# Set the working directory
WORKDIR /app/api

# Copy the dependencies file to the working directory
COPY requirements.txt .
COPY main.py .
# Copy the application files
COPY api/requirements.txt .
COPY api/main.py .

# Install any dependencies
# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the uploads directory
COPY ../uploads /app/uploads

# Change the ownership of the working directory to the non-root user
RUN chown -R appuser:appuser /app

# Create the uploads directory
RUN mkdir -p ../uploads

# Change the ownership of the uploads directory to the non-root user
RUN chown -R appuser:appuser ../uploads

# Switch to the non-root user
USER appuser

# Command to run the application
CMD ["sh", "-c", "exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 main:app"]

0 comments on commit d54b52e

Please sign in to comment.