From 65f3525ffd3c280b13dcb95024d05137d48eceea Mon Sep 17 00:00:00 2001
From: saundersp <pierre.saundersgb@gmail.com>
Date: Sun, 19 Jan 2025 22:42:53 +0100
Subject: [PATCH] Updated Dockerfile base image and fixed runtime permissions

---
 Dockerfile               | 16 +++++++++++++---
 docker-compose.yaml      |  6 +++++-
 haskell-playground.cabal |  2 +-
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 06e8759..b6547b1 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,11 +1,21 @@
-FROM haskell:9.2.8-slim-buster
+FROM haskell:9.4.8-slim-buster
+
+ARG UID=1000
+ARG GID=1000
+
+RUN groupadd -g ${GID} saundersp \
+	&& useradd -l -m -u "${UID}" -g "${GID}" saundersp
+
+USER saundersp
 
 WORKDIR /home/saundersp/haskell_playground
 
 RUN cabal update
 
-COPY . .
+COPY app app
+COPY haskell-playground.cabal .
 
 RUN cabal build
 
-ENTRYPOINT ["cabal", "run"]
+ENTRYPOINT ["cabal"]
+CMD ["run"]
diff --git a/docker-compose.yaml b/docker-compose.yaml
index b376a86..63aec66 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -2,6 +2,10 @@ services:
   haskell-playground:
     image: saundersp/haskell-playground
     pull_policy: never
-    build: .
+    build:
+      args:
+        UID: ${UID:-1000}
+        GID: ${GID:-1000}
+    user: ${UID:-1000}:${GID:-1000}
     volumes:
       - ./:/home/saundersp/haskell_playground
diff --git a/haskell-playground.cabal b/haskell-playground.cabal
index c24d167..daf6500 100644
--- a/haskell-playground.cabal
+++ b/haskell-playground.cabal
@@ -8,7 +8,7 @@ executable haskell-playground
     main-is:          Main.hs
     build-depends:
         primes,
-        base ^>=4.16.4.0
+        base ^>=4.17.2.1
     other-modules:
         Primes
         Problems