-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
67 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,51 @@ | ||
# Use an official Python runtime as a parent image | ||
FROM python:3.10 | ||
|
||
# Set the working directory in the container | ||
# Stage 1: Build stage | ||
FROM python:3.9-slim AS builder | ||
|
||
# Set environment variables for security and non-interactive installs | ||
ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONUNBUFFERED=1 \ | ||
PIP_DISABLE_PIP_VERSION_CHECK=1 \ | ||
PIP_DEFAULT_TIMEOUT=100 | ||
|
||
# Install system dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
gcc \ | ||
libpq-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copy requirements file | ||
COPY requirements.txt . | ||
|
||
# Copy the requirements.txt file into the container | ||
COPY requirements.txt /app | ||
# Install python dependencies in a temporary directory | ||
RUN pip install --prefix=/install -r requirements.txt | ||
|
||
# Install any dependencies | ||
RUN pip install -r requirements.txt | ||
# Stage 2: Production stage | ||
FROM python:3.9-slim | ||
|
||
# Copy the SusDB source code into the container | ||
COPY . /app | ||
# Set environment variables for security and non-interactive installs | ||
ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONUNBUFFERED=1 | ||
|
||
# Set the PYTHONPATH environment variable | ||
ENV PYTHONPATH=/app/src | ||
# Install system dependencies for runtime only (no build tools) | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
libpq-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy the script into the container | ||
COPY welcome_script.sh /usr/local/bin/welcome_script.sh | ||
# Copy the python dependencies from the build stage | ||
COPY --from=builder /install /usr/local | ||
|
||
# Make the script executable | ||
RUN chmod +x /usr/local/bin/welcome_script.sh | ||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Run the script when the container starts | ||
CMD ["/usr/local/bin/welcome_script.sh"] | ||
# Copy project files | ||
COPY . . | ||
|
||
ENV PYTHONPATH=/app/src | ||
|
||
RUN chmod +x welcome_script.sh | ||
|
||
CMD ["./welcome_script.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: '3.8' | ||
|
||
services: | ||
susdb: | ||
image: 590183661216.dkr.ecr.us-east-1.amazonaws.com/susdb:latest | ||
container_name: susdb | ||
ports: | ||
- 8000:8000 | ||
env_file: | ||
- .env |