Skip to content
This repository was archived by the owner on Jun 28, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
220445d
Rewriting Dockerfile and adding docker-compose support
hammady Oct 30, 2017
ad14741
Splitting API_URL to 2 variables depending on scenario
hammady Oct 30, 2017
095a1bd
Adding a README for docker-compose
hammady Oct 30, 2017
3c6f4bd
More in docker README about other images
hammady Oct 30, 2017
846cc02
Remove dependency on other docker images
hammady Dec 2, 2017
2f4ae16
Get CDN asset host from env ASSET_HOST
hammady Dec 2, 2017
1dba269
Use const instead of var for ASSET_HOST
hammady Dec 4, 2017
c9336a0
Merge remote-tracking branch 'upstream/master'
hammady Dec 17, 2017
7fb3640
Fix asset CDN to get fonts from fonts CDN
hammady Dec 20, 2017
7493bb9
Get asset host from env in production
hammady Dec 21, 2017
4ff388a
Remove .env, now variables loaded in compose
hammady Dec 31, 2017
e396754
Fix config not found in production
hammady Dec 31, 2017
111c0b7
Point assets to localhost till it is working
hammady Dec 31, 2017
7eed854
Setting api urls temporarily
hammady Dec 31, 2017
6aee214
Amend last commit after push :(
hammady Dec 31, 2017
e9870a7
Merge remote-tracking branch 'upstream/master'
hammady Jan 6, 2018
457b828
Fix Javascript errors
hammady Jan 8, 2018
ba42fa9
Fix fonts base URL
hammady Jan 8, 2018
6684f51
Select correct API URL (internal vs public)
hammady Jan 8, 2018
b2ee3ac
Create build-time environment variables for docker
hammady Jan 8, 2018
f107874
Add missing config for ASSET_HOST in prod.config.js
hammady Jan 8, 2018
2248eb3
Replace all page fonts by correct ones from CDN
hammady Jan 8, 2018
10790ba
Combine ASSET_HOST with FONTS_URL into one ASSETS_URL
hammady Jan 8, 2018
b9f07b8
Put correct values for build arguments
hammady Jan 13, 2018
5166da4
Fix eslint errors in metrics and server
hammady Jan 21, 2018
a57a1b2
Fix more eslint errors
hammady Jan 21, 2018
995be7e
Fix eslint error by importing config
hammady Jan 27, 2018
7f39c05
Remove fonts and move to a separate repo
hammady Jan 27, 2018
c3147df
Access fonts from a dedicated FONTS_URL env var
hammady Jan 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix asset CDN to get fonts from fonts CDN
  • Loading branch information
hammady committed Dec 20, 2017
commit 7fb364003e7e7f4422433cd7557c9e9fcd476be9
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ SENTRY_KEY_CLIENT=
SENTRY_KEY_SERVER=
# Quran.com - development app, no need to worry!
FACEBOOK_APP_ID=1599019233731707
ASSET_HOST=//assets-1f14.kxcdn.com
FONTS_URL=//quran-1f14.kxcdn.com
6 changes: 4 additions & 2 deletions docker-compose.production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ services:
- PUBLIC_API_URL=http://api.quran.com
- INTERNAL_API_URL=http://api.quran.com
#- INTERNAL_API_URL=http://api:3000
# - SEGMENTS_KEY=
# - SENTRY_KEY_CLIENT=https://app.getsentry.com
# - SENTRY_KEY_SERVER=https://app.getsentry.com
- FACEBOOK_APP_ID=appid
- ONE_QURAN_URL=https://one.quran.com
- PORT=8000
- ASSET_HOST=localhost:8000
#- ASSET_HOST=assets-1f14.kxcdn.com
#- ASSET_HOST=//localhost:8000
- ASSET_HOST=//assets-1f14.kxcdn.com
- FONTS_URL=//quran-1f14.kxcdn.com
ports:
- "8000:8000"

Expand Down
7 changes: 4 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ services:
environment:
- PUBLIC_API_URL=http://localhost:3000
- INTERNAL_API_URL=http://api:3000
# - SEGMENTS_KEY=
# - SENTRY_KEY_CLIENT=https://app.getsentry.com
# - SENTRY_KEY_SERVER=https://app.getsentry.com
- FACEBOOK_APP_ID=appid
- ONE_QURAN_URL=https://one.quran.com
- PORT=8000
- ASSET_HOST=localhost:8000
#- ASSET_HOST=assets-1f14.kxcdn.com
# TODO get all vars from .env (and remove dotenv module?)
- ASSET_HOST=//localhost:8000
#- ASSET_HOST=//assets-1f14.kxcdn.com
- FONTS_URL=//quran-1f14.kxcdn.com


3 changes: 2 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const config = {
sentryClient: process.env.SENTRY_KEY_CLIENT,
sentryServer: process.env.SENTRY_KEY_SERVER,
facebookAppId: process.env.FACEBOOK_APP_ID,
assetHost: process.env.ASSET_HOST,
fontsURL: process.env.FONTS_URL,
locales,
defaultLocale: 'en',
Expand Down Expand Up @@ -303,7 +304,7 @@ const config = {
},
{
rel: 'preconnect',
href: process.env.ASSET_HOST,
href: process.env.FONTS_URL,
crossOrigin: ''
},
{
Expand Down
14 changes: 6 additions & 8 deletions src/helpers/buildFontFaces.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/* eslint-disable max-len */

const assetHost = process.env.ASSET_HOST;

export const fontFaceStyle = fontClassName => (
`@font-face {font-family: '${fontClassName}';
src: url('//${assetHost}/fonts/compressed/eot/${fontClassName}.eot?#iefix') format('embedded-opentype'),
url('//${assetHost}/fonts/ttf/${fontClassName}.ttf') format('truetype'),
url('//${assetHost}/fonts/woff/${fontClassName}.woff?-snx2rh') format('woff');}
src: url('${config.fontsURL}/fonts/compressed/eot/${fontClassName}.eot?#iefix') format('embedded-opentype'),
url('${config.fontsURL}/fonts/ttf/${fontClassName}.ttf') format('truetype'),
url('${config.fontsURL}/fonts/woff/${fontClassName}.woff?-snx2rh') format('woff');}
.${fontClassName} {font-family: '${fontClassName}';}
.${fontClassName} {display: none;}`
);
Expand All @@ -27,9 +25,9 @@ export function createFontFacesArray(verses) {
fontFaces.push(font);
fontFacesArray.push(
`@font-face {font-family: '${font}';
src: url('//${assetHost}/fonts/compressed/eot/${font}.eot?#iefix') format('embedded-opentype'),
url('//${assetHost}/fonts/ttf/${font}.ttf') format('truetype'),
url('//${assetHost}/fonts/woff/${font}.woff?-snx2rh') format('woff');}
src: url('${config.fontsURL}/fonts/compressed/eot/${font}.eot?#iefix') format('embedded-opentype'),
url('${config.fontsURL}/fonts/ttf/${font}.ttf') format('truetype'),
url('${config.fontsURL}/fonts/woff/${font}.woff?-snx2rh') format('woff');}
.${font} {font-family: '${font}';}`
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/config/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ export default (server) => {
support(server);

server.get(/^\/(images|fonts)\/.*/, (req, res) => {
res.redirect(301, `//${process.env.ASSET_HOST}${req.path}`);
res.redirect(301, `${config.fontsURL}${req.path}`);
});
};