Skip to content

Commit 1f4e0b7

Browse files
authored
Merge pull request #203 from DefangLabs/jordan/apt-clean-after-install
consistenly clean up apt artifacts after apt-get install in slim images
2 parents 5b4774f + 139f27d commit 1f4e0b7

File tree

30 files changed

+110
-39
lines changed

30 files changed

+110
-39
lines changed

samples/django-postgres/app/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Use an official Python runtime as a parent image
22
FROM python:3.11-slim
33

4-
RUN apt-get update && apt-get install -y curl
4+
RUN apt-get update -qq \
5+
&& apt-get install -y curl \
6+
&& apt-get clean \
7+
&& rm -rf /var/lib/apt/lists/*
58

69
# Set environment variables
710
ENV PYTHONDONTWRITEBYTECODE 1

samples/django/app/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Use an official Python runtime as a parent image
22
FROM python:3.11-slim
33

4-
RUN apt-get update && apt-get install -y curl
4+
RUN apt-get update -qq \
5+
&& apt-get install -y curl \
6+
&& apt-get clean \
7+
&& rm -rf /var/lib/apt/lists/*
58

69
# Set environment variables
710
ENV PYTHONDONTWRITEBYTECODE 1

samples/fastapi-postgres/fastapi/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ FROM python:3.11-slim
55
WORKDIR /app
66

77
# Install required C++11 libraries and ca-certificates
8-
RUN apt-get update \
8+
RUN apt-get update -qq \
99
&& apt-get install -y \
1010
build-essential \
1111
python3-dev \
1212
ca-certificates \
13+
&& apt-get clean \
1314
&& rm -rf /var/lib/apt/lists/*
1415

1516
# Install any needed packages specified in requirements.txt

samples/fastapi/fastapi/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ FROM python:3.11-slim
55
WORKDIR /app
66

77
# Install required C++11 libraries and ca-certificates
8-
RUN apt-get update \
8+
RUN apt-get update -qq \
99
&& apt-get install -y \
1010
build-essential \
1111
python3-dev \
1212
ca-certificates \
13+
&& apt-get clean \
1314
&& rm -rf /var/lib/apt/lists/*
1415

1516
# Install any needed packages specified in requirements.txt

samples/flask/flask/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ FROM python:3.11-slim
55
WORKDIR /app
66

77
# Install required packages
8-
RUN apt-get update \
8+
RUN apt-get update -qq \
99
&& apt-get install -y --no-install-recommends \
1010
build-essential \
1111
python3-dev \
12+
&& apt-get clean \
1213
&& rm -rf /var/lib/apt/lists/*
1314

1415
# Copy the current directory contents into the container at /app
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
FROM mcr.microsoft.com/devcontainers/java:11-bookworm
22

33
# Install Maven
4-
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
5-
&& apt-get -y install --no-install-recommends maven
4+
RUN apt-get update \
5+
&& export DEBIAN_FRONTEND=noninteractive \
6+
&& apt-get -y install --no-install-recommends maven \
7+
&& apt-get clean \
8+
&& rm -rf /var/lib/apt/lists/*

samples/javalin/app/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ RUN mvn clean package
1515
# Stage 2: Create the runtime image
1616
FROM openjdk:17-jdk-slim
1717

18-
RUN apt-get update && apt-get install -y curl
18+
RUN apt-get update -qq \
19+
&& apt-get install -y curl \
20+
&& apt-get clean \
21+
&& rm -rf /var/lib/apt/lists/*
1922

2023
# Set the working directory
2124
WORKDIR /app

samples/langchain/app/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Use an official Python runtime as a parent image
22
FROM python:3.11-slim
33

4-
RUN apt-get update && apt-get install -y curl
4+
RUN apt-get update -qq \
5+
&& apt-get install -y curl \
6+
&& apt-get clean \
7+
&& rm -rf /var/lib/apt/lists/*
58

69
# Set the working directory in the container
710
WORKDIR /app

samples/nextjs-postgres/app/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ FROM node:20-bookworm-slim
2525
WORKDIR /app
2626

2727
# Install curl
28-
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
28+
RUN apt-get update -qq \
29+
&& apt-get install -y curl \
30+
&& apt-get clean \
31+
&& rm -rf /var/lib/apt/lists/*
2932

3033
# Copy only the necessary files from the build stage
3134
COPY --from=builder /app/package*.json ./
@@ -43,4 +46,4 @@ RUN addgroup --system appgroup && adduser --system appuser --ingroup appgroup
4346
USER appuser
4447

4548
# Start the application
46-
CMD ["npm", "start"]
49+
CMD ["npm", "start"]

samples/nodejs-chatroom/app/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Use the slim version of Node.js on Debian Bookworm as the base image
22
FROM node:20-bookworm-slim
33

4-
RUN apt-get update && apt-get install -y curl
4+
RUN apt-get update -qq \
5+
&& apt-get install -y curl \
6+
&& apt-get clean \
7+
&& rm -rf /var/lib/apt/lists/*
58

69
# Set the working directory to /app
710
WORKDIR /app

0 commit comments

Comments
 (0)