Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1158 Embed ghost blog articles in frontend app #1161

Merged
merged 17 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ GOOGLE_SECRET=
## Paypal ##
##############
# using 'sb' as sandbox. no need to put real sandbox key if you don't plan to test requests with backend webhooks
PAYPAL_CLIENT_ID=sb
PAYPAL_CLIENT_ID=sb

## Ghost ##
###########
GHOST_API_URL=https://blog.podkrepi.bg
GHOST_CONTENT_KEY=86ec17c4b9660acd66b6034682
7 changes: 6 additions & 1 deletion .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ jobs:
env:
NODE_ENV: production
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
GHOST_API_URL: https://blog.podkrepi.bg
GHOST_CONTENT_KEY: ${{ secrets.GHOST_CONTENT_KEY }}
with:
push: false
target: production
build-args: SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
build-args: |
SENTRY_AUTH_TOKEN=${{ env.SENTRY_AUTH_TOKEN }}
GHOST_API_URL=${{ env.GHOST_API_URL }}
GHOST_CONTENT_KEY=${{ env.GHOST_CONTENT_KEY }}
tags: ghcr.io/podkrepi-bg/frontend:pr

- name: Scan with Mondoo
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ jobs:
working-directory: ./frontend
run: yarn

- name: Build frontend
working-directory: ./frontend
run: yarn run next build

- name: Setup env
working-directory: ./frontend
run: cp .env.local.example .env.local

- name: Build frontend
working-directory: ./frontend
run: yarn run next build

- name: Wait on backend
uses: iFaxity/wait-on-action@v1
with:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ jobs:
env:
NODE_ENV: production
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
GHOST_API_URL: https://blog.podkrepi.bg
GHOST_CONTENT_KEY: ${{ secrets.GHOST_CONTENT_KEY }}
with:
push: true
target: production
build-args: |
SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
SENTRY_AUTH_TOKEN=${{ env.SENTRY_AUTH_TOKEN }}
GHOST_API_URL=${{ env.GHOST_API_URL }}
GHOST_CONTENT_KEY=${{ env.GHOST_CONTENT_KEY }}
VERSION=${{ env.VERSION }}
tags: ghcr.io/podkrepi-bg/frontend:${{ env.VERSION }}

Expand Down
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ FROM base AS builder
ARG VERSION=unversioned
ARG SENTRY_AUTH_TOKEN
ENV SENTRY_AUTH_TOKEN="$SENTRY_AUTH_TOKEN"
ARG GHOST_API_URL
ENV GHOST_API_URL="$GHOST_API_URL"
ARG GHOST_CONTENT_KEY
ENV GHOST_CONTENT_KEY="$GHOST_CONTENT_KEY"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why should these be part of the container? We can set them externally

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@imilchev I'm trying to fix the build running in check-pr and release procedure.

In order to do next build we need to have the static content downloaded from the blog instance.

We can hardcode them in the image, but that removes the ability to replace them via ENV variable, which contradicts with the 12factor rules.

Any ideas are welcome

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@imilchev It's gonna be awesome if we don't need that in the Dockerfile. I'll do a test now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well.. it doesn't pass

Check out https://github.com/podkrepi-bg/frontend/actions/runs/3534858086/jobs/5932216756

I'm reverting it for now

COPY --from=dependencies /app/node_modules /app/node_modules
COPY . /app

Expand Down
2 changes: 2 additions & 0 deletions manifests/base/config-web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ data:
app-url: https://podkrepi.bg
api-url: https://podkrepi.bg/api/v1
image-host: podkrepi.bg
ghost-api-url: https://blog.podkrepi.bg
ghost-content-key: 86ec17c4b9660acd66b6034682
10 changes: 10 additions & 0 deletions manifests/base/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ spec:
secretKeyRef:
name: secrets-web
key: paypal-client-id
- name: GHOST_API_URL
valueFrom:
configMapKeyRef:
name: config-web
key: ghost-api-url
- name: GHOST_CONTENT_KEY
valueFrom:
configMapKeyRef:
name: config-web
key: ghost-content-key
ports:
- containerPort: 3040
resources:
Expand Down
8 changes: 7 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ const moduleExports = {
CAMPAIGN: process.env.FEATURE_CAMPAIGN ?? false,
},
},
sentry: {
hideSourceMaps: true,
},
images: {
domains: [process.env.IMAGE_HOST ?? 'localhost'],
domains: [
process.env.IMAGE_HOST ?? 'localhost',
process.env.GHOST_API_URL?.replace('https://', '') || 'blog.podkrepi.bg',
],
},
async redirects() {
return [
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"predev": "shx test -e .env.local && exit 0 || shx echo 'You need to create .env.local file. Please check README.md!' && exit 1",
"dev": "yarn && next dev -p 3040",
"build": "yarn format && next build",
"build": "yarn && next build",
"start": "next start -p 3040",
"test": "jest --env=jsdom",
"test:e2e": "playwright test",
Expand Down Expand Up @@ -38,9 +38,11 @@
"@next/bundle-analyzer": "^12.1.0",
"@paypal/react-paypal-js": "^7.8.1",
"@react-pdf/renderer": "^3.0.1",
"@sentry/nextjs": "6.17.8",
"@sentry/nextjs": "7.21.1",
"@tanstack/react-query": "^4.16.1",
"@tryghost/content-api": "^1.11.4",
"@types/react-slick": "^0.23.10",
"@types/tryghost__content-api": "^1.3.11",
"@uppy/aws-s3": "2.0.5",
"@uppy/core": "2.1.1",
"@uppy/facebook": "2.0.4",
Expand Down Expand Up @@ -83,8 +85,8 @@
},
"devDependencies": {
"@playwright/test": "^1.24.2",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@types/cookie": "^0.4.1",
"@types/lodash.truncate": "^4.4.7",
"@types/lru-cache": "^5.1.1",
Expand Down
10 changes: 10 additions & 0 deletions public/locales/bg/blog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"title": "Блог",
"description": "Място за истории, идеи и добри каузи.",
"created-on": "Създаден на:",
"reading-time": {
"label": "Време за прочитане:",
"count_one": "{{count}} минутa",
"count_other": "{{count}} минути"
}
}
3 changes: 2 additions & 1 deletion public/locales/bg/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"logout": "Изход",
"register": "Регистрация",
"changePassword": "Смяна на парола",
"forgottenPassword": "Забравена парола?"
"forgottenPassword": "Забравена парола?",
"go-back": "Назад"
},
"meta": {
"title": "Подкрепи.бг"
Expand Down
10 changes: 10 additions & 0 deletions public/locales/en/blog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"title": "Blog",
"description": "A place for stories, ideas and good causes.",
"created-on": "Created on:",
"reading-time": {
"label": "Reading time:",
"count_one": "{{count}} minute",
"count_other": "{{count}} minutes"
}
}
3 changes: 2 additions & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"logout": "Logout",
"register": "Signup",
"changePassword": "Change your password",
"forgottenPassword": "Forgotten password?"
"forgottenPassword": "Forgotten password?",
"go-back": "Go back"
},
"meta": {
"title": "Podkrepi.bg"
Expand Down