From ea754538b949f3b7007923761162d91057eafd48 Mon Sep 17 00:00:00 2001
From: Varac <varac@varac.net>
Date: Tue, 25 Oct 2022 10:56:45 +0200
Subject: [PATCH] Lint and optimize Dockerfile with hadolint

---
 backend/Dockerfile | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/backend/Dockerfile b/backend/Dockerfile
index c343b6b6..f5e8e90c 100644
--- a/backend/Dockerfile
+++ b/backend/Dockerfile
@@ -1,22 +1,20 @@
 FROM python:3.11-slim
 
-RUN apt-get update
-RUN apt-get install -y gcc libffi-dev
-
 ## make a local directory
 RUN mkdir /app
 
 # set "app" as the working directory from which CMD, RUN, ADD references
 WORKDIR /app
 
-# copy requirements.txt to /app
-ADD requirements.txt .
-
-# pip install the local requirements.txt
-RUN pip install -r requirements.txt
+# now copy all the files in this directory to /app
+COPY . .
 
-# now copy all the files in this directory to /code
-ADD . .
+# hadolint ignore=DL3008
+RUN apt-get update \
+  && apt-get install --no-install-recommends -y gcc libffi-dev \
+  && apt-get clean \
+  && rm -rf /var/lib/apt/lists/* \
+  && pip install --no-cache-dir -r requirements.txt
 
 # Listen to port 80 at runtime
 EXPOSE 5000
-- 
GitLab