Skip to content

Commit

Permalink
🚀 make STRAPI_KEY a build-time secret
Browse files Browse the repository at this point in the history
  • Loading branch information
Oculux314 committed Sep 10, 2024
1 parent ab46d68 commit 34976ea
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: Fly Deploy
working-directory: ./next
run: flyctl deploy --remote-only --config fly.production.toml --dockerfile Dockerfile
run: flyctl deploy --remote-only --config fly.production.toml --dockerfile Dockerfile --build-arg STRAPI_KEY=${{ secrets.PRODUCTION_STRAPI_KEY }}
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_FRONTEND }}
deploy-storage:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: Fly Deploy
working-directory: ./next
run: flyctl deploy --remote-only --config fly.staging.toml --dockerfile Dockerfile
run: flyctl deploy --remote-only --config fly.staging.toml --dockerfile Dockerfile --build-arg STRAPI_KEY=${{ secrets.STAGING_STRAPI_KEY }}
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_FRONTEND_STAGING }}
deploy-storage:
Expand Down
1 change: 1 addition & 0 deletions next/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
dist
node_modules
.env
.next
13 changes: 9 additions & 4 deletions next/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ LABEL fly_launch_runtime="Next.js"
# Next.js app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"

# Install pnpm
# ARG PNPM_VERSION=8.3.1
# RUN npm install -g pnpm@$PNPM_VERSION
Expand All @@ -32,7 +29,15 @@ RUN npm install
COPY --link . .

# Build application
RUN npm run build
ARG STRAPI_KEY
ENV STRAPI_KEY=${STRAPI_KEY}

ENV NODE_ENV="production"
ENV STRAPI_URL="https://younite-strapi-staging.fly.dev"

RUN --mount=type=secret,id=STRAPI_KEY \
STRAPI_KEY="$(cat /run/secrets/STRAPI_KEY)" \
npm run build

# Remove development dependencies
# RUN pnpm prune --prod
Expand Down
Binary file modified strapi/.tmp/data.db
Binary file not shown.
2 changes: 1 addition & 1 deletion strapi/config/plugins.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = ({ env }) => {
const productionConfig =
process.env.NODE_ENV === "NEVER" // Should be process.env.NODE_ENV === "production"
process.env.NODE_ENV === "production" // Should be process.env.NODE_ENV === "production"
? {
upload: {
config: {
Expand Down

0 comments on commit 34976ea

Please sign in to comment.