-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove unnecessary APPLE_SILICON variable from Makefiles. * Optimize Dockefiles --------- Co-authored-by: mgonnav <mateo@emegona.com>
- Loading branch information
Showing
7 changed files
with
167 additions
and
89 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,40 +1,32 @@ | ||
FROM python:3.9 | ||
FROM python:3.9-slim | ||
|
||
WORKDIR /home/estela | ||
|
||
ARG APPLE_SILICON=false | ||
COPY estela-api/requirements ./requirements | ||
|
||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONUNBUFFERED=1 | ||
|
||
RUN apt-get update | ||
|
||
RUN apt-get install \ | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
build-essential \ | ||
curl \ | ||
git \ | ||
gnupg \ | ||
lsb-release -y | ||
|
||
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | ||
lsb-release \ | ||
unixodbc-dev \ | ||
default-libmysqlclient-dev \ | ||
&& curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg \ | ||
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list \ | ||
&& apt-get update \ | ||
&& apt-get install -y docker-ce docker-ce-cli containerd.io \ | ||
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN echo \ | ||
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ | ||
focal stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
|
||
RUN apt-get update | ||
|
||
RUN apt-get install docker-ce docker-ce-cli containerd.io -y | ||
|
||
# If an Apple Silicon chip is used, install pyodbc and unixodbc-dev | ||
RUN if [ "$APPLE_SILICON" = "true" ]; then \ | ||
apt-get update && apt-get install -y unixodbc-dev && \ | ||
pip install --no-binary :all: pyodbc && \ | ||
sed -i '/pyodbc/d' requirements/deploy.txt; \ | ||
fi | ||
COPY estela-api/requirements ./requirements | ||
|
||
RUN pip install -r requirements/deploy.txt | ||
RUN if test -f "requirements/externalApps.txt"; then pip install -r requirements/externalApps.txt; fi | ||
# Install Python dependencies | ||
RUN pip install --no-cache-dir -r requirements/deploy.txt \ | ||
&& { [ -f requirements/externalApps.txt ] && pip install --no-cache-dir -r requirements/externalApps.txt || true; } | ||
|
||
COPY estela-api/ estela-api/ | ||
COPY database_adapters/ estela-api/database_adapters/ |
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,23 +1,44 @@ | ||
FROM python:3.9 | ||
# Build Stage | ||
FROM python:3.9-slim as builder | ||
|
||
ARG APPLE_SILICON=false | ||
ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONUNBUFFERED=1 | ||
|
||
WORKDIR /home/estela | ||
WORKDIR /build | ||
|
||
# Install build dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
git \ | ||
build-essential \ | ||
unixodbc-dev \ | ||
default-libmysqlclient-dev \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY estela-api/requirements ./requirements | ||
|
||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
RUN pip install --no-cache-dir --target=/build/deps -r requirements/test.txt \ | ||
&& if [ -f requirements/externalApps.txt ]; then pip install --no-cache-dir --target=/build/deps -r requirements/externalApps.txt; fi | ||
|
||
|
||
# Final Stage | ||
FROM python:3.9-slim | ||
|
||
# If an Apple Silicon chip is used, install pyodbc and unixodbc-dev | ||
RUN if [ "$APPLE_SILICON" = "true" ]; then \ | ||
apt-get update && apt-get install -y unixodbc-dev && \ | ||
pip install --no-binary :all: pyodbc && \ | ||
sed -i '/pyodbc/d' requirements/test.txt; \ | ||
fi | ||
|
||
RUN pip install -r requirements/test.txt | ||
RUN if test -f "requirements/externalApps.txt"; then pip install -r requirements/externalApps.txt; fi | ||
ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONUNBUFFERED=1 | ||
|
||
WORKDIR /home/estela | ||
|
||
# Copy installed dependencies from the builder stage | ||
COPY --from=builder /build/deps /usr/local/lib/python3.9/site-packages | ||
COPY --from=builder /build/deps/bin /usr/local/bin | ||
|
||
COPY estela-api/ . | ||
COPY database_adapters/ ./database_adapters | ||
|
||
# Runtime dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
unixodbc-dev \ | ||
default-libmysqlclient-dev \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* |
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,23 +1,44 @@ | ||
FROM python:3.9 | ||
# Build Stage | ||
FROM python:3.9-slim as builder | ||
|
||
ARG APPLE_SILICON=false | ||
ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONUNBUFFERED=1 | ||
|
||
WORKDIR /home/estela | ||
WORKDIR /build | ||
|
||
# Install build dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
git \ | ||
build-essential \ | ||
unixodbc-dev \ | ||
default-libmysqlclient-dev \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY estela-api/requirements ./requirements | ||
|
||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
RUN pip install --no-cache-dir --target=/build/deps -r requirements/test.txt \ | ||
&& if [ -f requirements/externalApps.txt ]; then pip install --no-cache-dir --target=/build/deps -r requirements/externalApps.txt; fi | ||
|
||
# If an Apple Silicon chip is used, install pyodbc and unixodbc-dev | ||
RUN if [ "$APPLE_SILICON" = "true" ]; then \ | ||
apt-get update && apt-get install -y unixodbc-dev && \ | ||
pip install --no-binary :all: pyodbc && \ | ||
sed -i '/pyodbc/d' requirements/test.txt; \ | ||
fi | ||
|
||
RUN pip install -r requirements/test.txt | ||
RUN if test -f "requirements/externalApps.txt"; then pip install -r requirements/externalApps.txt; fi | ||
# Final Stage | ||
FROM python:3.9-slim | ||
|
||
ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONUNBUFFERED=1 | ||
|
||
WORKDIR /home/estela | ||
|
||
# Copy installed dependencies from the builder stage | ||
COPY --from=builder /build/deps /usr/local/lib/python3.9/site-packages | ||
COPY --from=builder /build/deps/bin /usr/local/bin | ||
|
||
COPY estela-api/ . | ||
COPY database_adapters/ ./database_adapters | ||
|
||
# Runtime dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
unixodbc-dev \ | ||
default-libmysqlclient-dev \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* |
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,24 +1,45 @@ | ||
FROM python:3.9 | ||
# Build Stage | ||
FROM python:3.9-slim as builder | ||
|
||
WORKDIR /home/estela | ||
ARG APPLE_SILICON=false | ||
ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONUNBUFFERED=1 | ||
|
||
WORKDIR /build | ||
|
||
# Install build dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
git \ | ||
build-essential \ | ||
unixodbc-dev \ | ||
default-libmysqlclient-dev \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY estela-api/requirements ./requirements | ||
|
||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
RUN pip install --no-cache-dir --target=/build/deps -r requirements/test.txt \ | ||
&& if [ -f requirements/externalApps.txt ]; then pip install --no-cache-dir --target=/build/deps -r requirements/externalApps.txt; fi | ||
|
||
|
||
# If an Apple Silicon chip is used, install pyodbc and unixodbc-dev | ||
RUN if [ "$APPLE_SILICON" = "true" ]; then \ | ||
apt-get update && apt-get install -y unixodbc-dev && \ | ||
pip install --no-binary :all: pyodbc && \ | ||
sed -i '/pyodbc/d' requirements/test.txt; \ | ||
fi | ||
# Final Stage | ||
FROM python:3.9-slim | ||
|
||
RUN pip install -r requirements/test.txt | ||
RUN if test -f "requirements/externalApps.txt"; then pip install -r requirements/externalApps.txt; fi | ||
ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONUNBUFFERED=1 | ||
|
||
WORKDIR /home/estela | ||
|
||
# Copy installed dependencies from the builder stage | ||
COPY --from=builder /build/deps /usr/local/lib/python3.9/site-packages | ||
|
||
COPY estela-api/ . | ||
COPY database_adapters/ ./database_adapters | ||
|
||
# Runtime dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
unixodbc-dev \ | ||
default-libmysqlclient-dev \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
EXPOSE 8000 |
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,21 +1,45 @@ | ||
FROM python:3.9 | ||
# Build Stage | ||
FROM python:3.9-slim as builder | ||
|
||
ARG APPLE_SILICON=false | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONUNBUFFERED=1 | ||
|
||
WORKDIR /home/estela | ||
WORKDIR /build | ||
|
||
# Install build dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
git \ | ||
build-essential \ | ||
unixodbc-dev \ | ||
default-libmysqlclient-dev \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY queueing/requirements requirements | ||
RUN if [ "$APPLE_SILICON" = "true" ]; then \ | ||
apt-get update && apt-get install -y unixodbc-dev && \ | ||
pip install --no-binary :all: pyodbc && \ | ||
sed -i '/pyodbc/d' requirements/consumer.txt; \ | ||
fi | ||
RUN pip install -r requirements/consumer.txt | ||
|
||
RUN pip install --no-cache-dir --target=/build/deps -r requirements/consumer.txt | ||
|
||
|
||
# Final Stage | ||
FROM python:3.9-slim | ||
|
||
ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONUNBUFFERED=1 | ||
|
||
WORKDIR /home/estela | ||
|
||
# Copy installed dependencies from the builder stage | ||
COPY --from=builder /build/deps /usr/local/lib/python3.9/site-packages | ||
|
||
COPY queueing/consumer.py . | ||
COPY queueing/inserter.py . | ||
COPY queueing/utils.py . | ||
COPY queueing/config config | ||
COPY database_adapters/ ./database_adapters | ||
|
||
# Runtime dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
unixodbc-dev \ | ||
default-libmysqlclient-dev \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* |