docker and workflow fixed for runtime VAPID
This commit is contained in:
parent
e83f576984
commit
e348d2984a
10
.github/workflows/deploy-ec2.yml
vendored
10
.github/workflows/deploy-ec2.yml
vendored
@ -27,6 +27,14 @@ jobs:
|
|||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
# Next.js embeds NEXT_PUBLIC_* at build time. Create .env from EC2_ENV so the Docker build sees it.
|
||||||
|
- name: Create .env for build
|
||||||
|
run: |
|
||||||
|
cat > .env << 'ENVFILE'
|
||||||
|
${{ secrets.EC2_ENV }}
|
||||||
|
ENVFILE
|
||||||
|
echo "NEXT_PUBLIC_VAPID_PUBLIC_KEY is set: $(grep -q 'NEXT_PUBLIC_VAPID_PUBLIC_KEY=.' .env && echo yes || echo no)"
|
||||||
|
|
||||||
- name: Build application image
|
- name: Build application image
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
@ -37,8 +45,6 @@ jobs:
|
|||||||
tags: ${{ env.IMAGE_NAME }}:latest
|
tags: ${{ env.IMAGE_NAME }}:latest
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
build-args: |
|
|
||||||
NEXT_PUBLIC_VAPID_PUBLIC_KEY=${{ secrets.NEXT_PUBLIC_VAPID_PUBLIC_KEY }}
|
|
||||||
|
|
||||||
- name: Save application image
|
- name: Save application image
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@ -9,14 +9,10 @@ COPY prisma ./prisma
|
|||||||
# Install ALL dependencies (including devDependencies needed for build)
|
# Install ALL dependencies (including devDependencies needed for build)
|
||||||
RUN npm ci && npx prisma generate
|
RUN npm ci && npx prisma generate
|
||||||
|
|
||||||
# Copy application code
|
# Copy application code (includes .env created in CI from EC2_ENV for NEXT_PUBLIC_* at build time)
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build-time env vars (NEXT_PUBLIC_* are embedded into the JS bundle)
|
# Build the Next.js application (reads .env and embeds NEXT_PUBLIC_* into the bundle)
|
||||||
ARG NEXT_PUBLIC_VAPID_PUBLIC_KEY
|
|
||||||
ENV NEXT_PUBLIC_VAPID_PUBLIC_KEY=$NEXT_PUBLIC_VAPID_PUBLIC_KEY
|
|
||||||
|
|
||||||
# Build the Next.js application
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Copy and set up entrypoint script
|
# Copy and set up entrypoint script
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user