-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🎸 docker reduced size by 2 (#1653)
reduced size by 2 # Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
- Loading branch information
1 parent
efe4e8c
commit 744eea6
Showing
11 changed files
with
91 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,3 +70,4 @@ backend/bin/* | |
backend/lib/* | ||
backend/pyvenv.cfg | ||
backend/share/* | ||
backend/slim.report.json |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
**/__pycache__ | ||
*/.pytest_cache | ||
**/__pycache__ | ||
**/.benchmarks/ | ||
**/.cache/ | ||
**/.pytest_cache/ | ||
**/.next/ | ||
**/build/ | ||
**/.docusaurus/ | ||
**/node_modules/ |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Using a slim version for a smaller base image | ||
FROM python:3.11.6-slim-bullseye | ||
|
||
ARG DEV_MODE | ||
ENV DEV_MODE=$DEV_MODE | ||
|
||
# Install GEOS library, Rust, and other dependencies, then clean up | ||
RUN apt-get clean && apt-get update && apt-get install -y \ | ||
libgeos-dev \ | ||
libcurl4-openssl-dev \ | ||
libssl-dev \ | ||
binutils \ | ||
pandoc \ | ||
curl \ | ||
git \ | ||
build-essential && \ | ||
rm -rf /var/lib/apt/lists/* && apt-get clean | ||
|
||
# Add Rust binaries to the PATH | ||
ENV PATH="/root/.cargo/bin:${PATH}" | ||
|
||
WORKDIR /code | ||
|
||
# Copy just the requirements first | ||
COPY ./requirements.txt . | ||
|
||
# Upgrade pip | ||
RUN pip install --upgrade pip | ||
|
||
# Increase timeout to wait for the new installation | ||
RUN pip install --no-cache-dir -r requirements.txt --timeout 200 | ||
|
||
RUN if [ "$DEV_MODE" = "true" ]; then pip install --no-cache debugpy --timeout 200; fi | ||
|
||
# Copy the rest of the application | ||
COPY . . | ||
|
||
EXPOSE 5050 | ||
|
||
CMD ["uvicorn", "main:app","--reload", "--host", "0.0.0.0", "--port", "5050", "--workers", "6"] |
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
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
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,2 +1,13 @@ | ||
.next/ | ||
node_modules/ | ||
**/.next/ | ||
**/node_modules/ | ||
**/.vercel/ | ||
**/__pycache__ | ||
*/.pytest_cache | ||
**/__pycache__ | ||
**/.benchmarks/ | ||
**/.cache/ | ||
**/.pytest_cache/ | ||
**/.next/ | ||
**/build/ | ||
**/.docusaurus/ | ||
**/node_modules/ |
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,49 +1,31 @@ | ||
# First stage: Build environment | ||
FROM node:18.13.0-alpine as builder | ||
|
||
FROM node:18.13.0-alpine | ||
# Install Python and essential build tools | ||
RUN apk add --update --no-cache python3 make g++ && ln -sf python3 /usr/bin/python | ||
RUN python3 -m ensurepip | ||
RUN pip3 install --no-cache --upgrade pip setuptools | ||
|
||
# Create a Python virtual environment | ||
RUN python3 -m venv /venv | ||
ENV PATH="/venv/bin:$PATH" | ||
|
||
# Create the directory where our app will live | ||
# Create the directory on the node image | ||
# where our Next.js app will live | ||
RUN mkdir -p /app | ||
|
||
# Set /app as the working directory | ||
WORKDIR /app | ||
|
||
# Copy package.json and yarn.lock to the working directory | ||
# Copy package.json and yarn.lock | ||
# to the /app working directory | ||
COPY package*.json yarn.lock ./ | ||
|
||
# Install Node.js dependencies | ||
# Install dependencies in /app | ||
RUN yarn install --network-timeout 1000000 | ||
|
||
# Copy the rest of the Next.js folder into /app | ||
# Copy the rest of our Next.js folder into /app | ||
COPY . . | ||
|
||
# Build the Next.js application | ||
RUN yarn build | ||
|
||
# Second stage: Runtime environment | ||
FROM node:18.13.0-alpine | ||
|
||
# Copy the virtual environment from the builder stage | ||
COPY --from=builder /venv /venv | ||
ENV PATH="/venv/bin:$PATH" | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy built assets from the builder stage | ||
COPY --from=builder /app/.next ./.next | ||
COPY --from=builder /app/node_modules ./node_modules | ||
COPY --from=builder /app/package.json ./package.json | ||
COPY --from=builder /app/public ./public | ||
|
||
# Ensure port 3000 is accessible to our system | ||
EXPOSE 3000 | ||
|
||
# Run yarn start, as we would via the command line | ||
# Run yarn start, as we would via the command line | ||
CMD ["yarn", "start"] |