Skip to content

Commit 5825a37

Browse files
Added prisma submodule check to fix docker build cache issue when copying prisma folder.
1 parent b0d0b74 commit 5825a37

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

.github/workflows/deploy.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,12 @@ jobs:
9696
9797
# Step 4: Build the latest api image.
9898
echo "Building the latest api image..."
99-
# Use 'codebuilder' as the stack prefix
100-
docker compose -p codebuilder build api
99+
# Get the current commit hash of the prisma submodule
100+
# This ensures Docker rebuilds the prisma layer when the submodule is updated
101+
PRISMA_COMMIT=$(git submodule status prisma | awk '{print $1}' | sed 's/^+//')
102+
echo "Using Prisma submodule commit: $PRISMA_COMMIT"
103+
# Use 'codebuilder' as the stack prefix with build-arg to bust cache
104+
docker compose -p codebuilder build --build-arg PRISMA_COMMIT=$PRISMA_COMMIT api
101105
102106
# Step 5: Forcefully remove the old api container to prevent conflicts.
103107
echo "Forcefully removing old api container if it exists..."

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ RUN npm install -g pnpm
99

1010
# Copy package manifests and lockfile
1111
COPY package.json pnpm-lock.yaml ./
12+
13+
# Add a build argument to bust cache when the submodule changes
14+
# This ensures that Docker will re-copy the prisma directory when the submodule is updated
15+
ARG PRISMA_COMMIT
16+
# Copy the prisma directory
1217
COPY prisma ./prisma
1318

1419

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ services:
2525
build:
2626
context: .
2727
dockerfile: Dockerfile
28+
args:
29+
- PRISMA_COMMIT=${PRISMA_COMMIT:-latest}
2830
container_name: codebuilder-api
2931
restart: unless-stopped
3032
env_file:

0 commit comments

Comments
 (0)