Skip to content

Commit

Permalink
test(deploy): env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
chengpeiquan committed Nov 29, 2024
1 parent 4895b1a commit 674afab
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
- name: build docker image
run: |
docker build . \
--build-arg HELLO=hello \
--build-arg WORLD=world \
--build-arg HELLO_WORLD=${{ secrets.HELLO_WORLD }} \
--build-arg NEXT_PUBLIC_HELLO=hello \
--build-arg NEXT_PUBLIC_WORLD=world \
--build-arg NEXT_PUBLIC_HELLO_WORLD=${{ secrets.HELLO_WORLD }} \
--file Dockerfile \
--tag ${{ secrets.DOCKER_IMAGE }}
- name: publish docker image
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ WORKDIR /app
ENV NODE_ENV=production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED=1
ENV HELLO=${HELLO}
ENV WORLD=${WORLD}
ENV HELLO_WORLD=${HELLO_WORLD}
ENV HELLO=${NEXT_PUBLIC_HELLO}
ENV WORLD=${NEXT_PUBLIC_WORLD}
ENV HELLO_WORLD=${NEXT_PUBLIC_HELLO_WORLD}

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
Expand Down
8 changes: 7 additions & 1 deletion src/app/api/hello/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
export async function GET() {
const data = {
HELLO: process.env.NEXT_PUBLIC_HELLO,
WORLD: process.env.NEXT_PUBLIC_WORLD,
HELLO_WORLD: process.env.NEXT_PUBLIC_HELLO_WORLD,
}

return Response.json({
data: process.env,
data,
})
}

0 comments on commit 674afab

Please sign in to comment.