Skip to content

Commit be4e253

Browse files
committed
add build argument for commit SHA to Dockerfile and update deploy command in workflow
1 parent 59a81c8 commit be4e253

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

.github/workflows/validate.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ jobs:
7676
uses: superfly/flyctl-actions/[email protected]
7777

7878
- name: 🚀 Deploy
79-
run: flyctl deploy --remote-only
79+
run:
80+
flyctl deploy --remote-only --build-arg EPICSHOP_COMMIT_SHA=${{
81+
github.sha }}
8082
working-directory: ./epicshop
8183
env:
8284
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

epicshop/Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,19 @@ ENV FLY="true"
1111
ENV PORT="8080"
1212
ENV NODE_ENV="production"
1313

14+
# Build argument for commit SHA to bust cache when repo changes
15+
ARG EPICSHOP_COMMIT_SHA
16+
ENV EPICSHOP_COMMIT_SHA=${EPICSHOP_COMMIT_SHA}
17+
1418
WORKDIR /myapp
1519

1620
# Clone the workshop repo during build time, excluding database files
17-
RUN git clone --depth 1 ${EPICSHOP_GITHUB_REPO} ${EPICSHOP_CONTEXT_CWD}
21+
# Clone specific commit to keep image small while ensuring cache busting
22+
RUN git init ${EPICSHOP_CONTEXT_CWD} && \
23+
cd ${EPICSHOP_CONTEXT_CWD} && \
24+
git remote add origin ${EPICSHOP_GITHUB_REPO} && \
25+
git fetch --depth 1 origin ${EPICSHOP_COMMIT_SHA} && \
26+
git checkout ${EPICSHOP_COMMIT_SHA}
1827

1928
ADD . .
2029

0 commit comments

Comments
 (0)