Skip to content

Commit

Permalink
refactor: align env var convention
Browse files Browse the repository at this point in the history
  • Loading branch information
sethidden committed Apr 4, 2022
1 parent 52818e3 commit a079b0e
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 56 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/deploy-vue-storefront-cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ jobs:
password: ${{ secrets.CLOUD_PASSWORD }}
dockerfile: .vuestorefrontcloud/docker/Dockerfile
buildoptions: --compress
buildargs: NPM_EMAIL,NPM_PASS,NPM_USER,NPM_REGISTRY,STORE_URL,MAGENTO_GRAPHQL,MAGENTO_EXTERNAL_CHECKOUT,MAGENTO_EXTERNAL_CHECKOUT_URL,MAGENTO_EXTERNAL_CHECKOUT_SYNC_PATH,IMAGE_PROVIDER,IMAGE_PROVIDER_BASE_URL,REDIS__HOST,REDIS__PORT,REDIS__CACHE_INVALIDATE_KEY,REDIS__CACHE_INVALIDATE_URL,REDIS__KEY_PREFIX,REDIS__ENABLED,SENTRY_DSN,RECAPTCHA_SITE_KEY,RECAPTCHA_SECRET_KEY
buildargs: NPM_EMAIL,NPM_PASS,NPM_USER,NPM_REGISTRY,STORE_URL,MAGENTO_GRAPHQL,MAGENTO_EXTERNAL_CHECKOUT,MAGENTO_EXTERNAL_CHECKOUT_URL,MAGENTO_EXTERNAL_CHECKOUT_SYNC_PATH,IMAGE_PROVIDER,IMAGE_PROVIDER_BASE_URL,REDIS_HOST,REDIS_PORT,REDIS_CACHE_INVALIDATE_KEY,REDIS_CACHE_INVALIDATE_URL,REDIS_KEY_PREFIX,REDIS_ENABLED,SENTRY_DSN,RECAPTCHA_SITE_KEY,RECAPTCHA_SECRET_KEY
env:
NPM_EMAIL: ${{ secrets.NPM_EMAIL }}
NPM_PASS: ${{ secrets.CLOUD_PASSWORD }}
NPM_USER: ${{ secrets.CLOUD_USERNAME }}
NPM_REGISTRY: https://registrynpm.storefrontcloud.io
STORE_URL: ${{ secrets.STORE_URL }}
MAGENTO_GRAPHQL: ${{ secrets.MAGENTO_GRAPHQL }}
MAGENTO_EXTERNAL_CHECKOUT: ${{ secrets.MAGENTO_EXTERNAL_CHECKOUT }}
MAGENTO_EXTERNAL_CHECKOUT_ENABLED: ${{ secrets.MAGENTO_EXTERNAL_CHECKOUT_ENABLED }}
MAGENTO_EXTERNAL_CHECKOUT_URL: ${{ secrets.MAGENTO_EXTERNAL_CHECKOUT_URL }}
MAGENTO_EXTERNAL_CHECKOUT_SYNC_PATH: ${{ secrets.MAGENTO_EXTERNAL_CHECKOUT_SYNC_PATH }}
IMAGE_PROVIDER: ${{ secrets.IMAGE_PROVIDER }}
IMAGE_PROVIDER_BASE_URL: ${{ secrets.IMAGE_PROVIDER_BASE_URL }}
REDIS__HOST: ${{ secrets.REDIS__HOST }}
REDIS__PORT: ${{ secrets.REDIS__PORT }}
REDIS__KEY_PREFIX: ${{ github.sha }}
REDIS__CACHE_INVALIDATE_KEY: ${{ secrets.REDIS__CACHE_INVALIDATE_KEY }}
REDIS__CACHE_INVALIDATE_URL: ${{ secrets.REDIS__CACHE_INVALIDATE_URL }}
REDIS__ENABLED: ${{ secrets.REDIS__ENABLED }}
REDIS_HOST: ${{ secrets.REDIS_HOST }}
REDIS_PORT: ${{ secrets.REDIS_PORT }}
REDIS_KEY_PREFIX: ${{ github.sha }}
REDIS_CACHE_INVALIDATE_KEY: ${{ secrets.REDIS_CACHE_INVALIDATE_KEY }}
REDIS_CACHE_INVALIDATE_URL: ${{ secrets.REDIS_CACHE_INVALIDATE_URL }}
REDIS_ENABLED: ${{ secrets.REDIS_ENABLED }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
RECAPTCHA_SITE_KEY: ${{ secrets.RECAPTCHA_SITE_KEY }}
RECAPTCHA_SECRET_KEY: ${{ secrets.RECAPTCHA_SECRET_KEY }}
Expand Down
22 changes: 11 additions & 11 deletions .vuestorefrontcloud/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ ARG NPM_USER
ARG NPM_PASS
ARG NPM_EMAIL
ARG NPM_REGISTRY
ARG MAGENTO_EXTERNAL_CHECKOUT
ARG MAGENTO_EXTERNAL_CHECKOUT_ENABLED
ARG MAGENTO_EXTERNAL_CHECKOUT_SYNC_PATH
ARG STORE_URL
ARG IMAGE_PROVIDER_BASE_URL
ARG REDIS__HOST
ARG REDIS__PORT
ARG REDIS__CACHE_INVALIDATE_KEY
ARG REDIS_HOST
ARG REDIS_PORT
ARG REDIS_CACHE_INVALIDATE_KEY
ARG RECAPTCHA_ENABLED
ARG RECAPTCHA_HIDE_BADGE
ARG RECAPTCHA_VERSION
Expand All @@ -21,8 +21,8 @@ ARG RECAPTCHA_SITE_KEY
ARG RECAPTCHA_SECRET_KEY

ENV MAGENTO_GRAPHQL=https://magento2-instance.vuestorefront.io:8443/graphql
ENV MAGENTO_EXTERNAL_CHECKOUT_ENABLED=${MAGENTO_EXTERNAL_CHECKOUT}
ENV MAGENTO_EXTERNAL_CHECKOUT_URL=https://magento2-instance.vuestorefront.io
ENV MAGENTO_EXTERNAL_CHECKOUT=${MAGENTO_EXTERNAL_CHECKOUT}
ENV MAGENTO_EXTERNAL_CHECKOUT_SYNC_PATH=${MAGENTO_EXTERNAL_CHECKOUT_SYNC_PATH}
ENV STORE_URL=${STORE_URL}
ENV LAST_COMMIT=${COMMIT}
Expand All @@ -32,12 +32,12 @@ ENV NUXT_APP_PORT=3000
ENV MAGENTO_BASE_URL=https://magento2-instance.vuestorefront.io/
ENV IMAGE_PROVIDER=cloudinary
ENV IMAGE_PROVIDER_BASE_URL=${IMAGE_PROVIDER_BASE_URL}
ENV REDIS__HOST=${REDIS__HOST}
ENV REDIS__PORT=${REDIS__PORT}
ENV REDIS__CACHE_INVALIDATE_KEY=${REDIS__CACHE_INVALIDATE_KEY}
ENV REDIS__CACHE_INVALIDATE_URL=/cache-invalidate
ENV REDIS__KEY_PREFIX=magento2vsf2
ENV REDIS__ENABLED=true
ENV REDIS_HOST=${REDIS_HOST}
ENV REDIS_PORT=${REDIS_PORT}
ENV REDIS_CACHE_INVALIDATE_KEY=${REDIS_CACHE_INVALIDATE_KEY}
ENV REDIS_CACHE_INVALIDATE_URL=/cache-invalidate
ENV REDIS_KEY_PREFIX=magento2vsf2
ENV REDIS_ENABLED=true
ENV SENTRY_DSN=${SENTRY_DSN}
ENV RECAPTCHA_ENABLED=false
ENV RECAPTCHA_HIDE_BADGE=false
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ STORE_ENV=dev # Store environment (Usage for file configuration)
NUXT_APP_ENV=development # Define nuxt application environment
NUXT_APP_PORT=3000 # Define nuxt port
MAGENTO_GRAPHQL=https://{YOUR_SITE_FRONT_URL}/graphql # Define Magento GraphQL endpoint
MAGENTO_EXTERNAL_CHECKOUT=false # Flag if VSF will use External Checkout
MAGENTO_EXTERNAL_CHECKOUT_ENABLED=false # Flag if VSF will use External Checkout
MAGENTO_EXTERNAL_CHECKOUT_URL=https://{YOUR_SITE_FRONT_URL} # External checkout URL
MAGENTO_EXTERNAL_CHECKOUT_SYNC_PATH=/vue/cart/sync # External Checkout synchronization path
MAGENTO_BASE_URL={YOUR_SITE_FRONT_URL} # base url of your Magento instance
Expand Down
26 changes: 13 additions & 13 deletions docs/guide/ssr.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ The cached pages are:

To invalidate a tag and remove pages associated with that tag, use the [Invalidation endpoint](https://docs.vuestorefront.io/v2/performance/ssr-cache.html#invalidating-tags).

Go to the route configured in the `.env` file under the `REDIS__CACHE_INVALIDATE_KEY` key with two query parameters:
* `key` — string matching the `REDIS__CACHE_INVALIDATE_KEY` key in the `.env` file.
Go to the route configured in the `.env` file under the `REDIS_CACHE_INVALIDATE_KEY` key with two query parameters:
* `key` — string matching the `REDIS_CACHE_INVALIDATE_KEY` key in the `.env` file.
* `tags` — a comma-separated list of tags for invalidation.

Assuming that you are running the application locally, the `REDIS__CACHE_INVALIDATE_URL` key is equal to `/cache-invalidate,` and the `REDIS__CACHE_INVALIDATE_KEY` key is equal to `secret_key`, and you want to invalidate the `Vhome` tag, the full URL will look like this:
Assuming that you are running the application locally, the `REDIS_CACHE_INVALIDATE_URL` key is equal to `/cache-invalidate,` and the `REDIS_CACHE_INVALIDATE_KEY` key is equal to `secret_key`, and you want to invalidate the `Vhome` tag, the full URL will look like this:

## How to cache other pages

Expand Down Expand Up @@ -50,22 +50,22 @@ Once you have the Redis driver installed, you need to add the Redis configuratio

```
.env
REDIS__HOST=127.0.0.1
REDIS__PORT=6379
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS__KEY_PREFIX=
REDIS__CACHE_INVALIDATE_URL=/cache-invalidate
REDIS__ENABLED=false
REDIS_KEY_PREFIX=
REDIS_CACHE_INVALIDATE_URL=/cache-invalidate
REDIS_ENABLED=true
```

Then you have to update `nuxt.config.js file` and add this to the `modules` object:

```javascript
['@vue-storefront/cache/nuxt', {
enabled: process.env.REDIS__ENABLED,
enabled: process.env.REDIS_ENABLED,
invalidation: {
endpoint: process.env.REDIS__CACHE_INVALIDATE_URL,
key: process.env.REDIS__CACHE_INVALIDATE_KEY,
endpoint: process.env.REDIS_CACHE_INVALIDATE_URL,
key: process.env.REDIS_CACHE_INVALIDATE_KEY,
handlers: [
'@vue-storefront/cache/defaultHandler',
],
Expand All @@ -76,8 +76,8 @@ Then you have to update `nuxt.config.js file` and add this to the `modules` obje
// docs: https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options
redis: {
keyPrefix: process.env.REDIS__KEY_PREFIX,
host: process.env.REDIS__HOST,
port: process.env.REDIS__PORT,
host: process.env.REDIS_HOST,
port: process.env.REDIS_PORT,
},
},
],
Expand Down
26 changes: 15 additions & 11 deletions packages/theme/.env.example
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
STORE_URL=http://localhost:3000
NUXT_APP_ENV=development
NUXT_APP_PORT=3000

MAGENTO_BASE_URL={YOUR_SITE_FRONT_URL}
MAGENTO_GRAPHQL=https://{YOUR_SITE_FRONT_URL}/graphql
MAGENTO_EXTERNAL_CHECKOUT=false

MAGENTO_EXTERNAL_CHECKOUT_ENABLED=false
MAGENTO_EXTERNAL_CHECKOUT_URL=https://{YOUR_SITE_FRONT_URL}
MAGENTO_EXTERNAL_CHECKOUT_SYNC_PATH=/vue/cart/sync
MAGENTO_BASE_URL={YOUR_SITE_FRONT_URL}

IMAGE_PROVIDER=ipx
IMAGE_PROVIDER_BASE_URL={YOUR_IMAGE_PROVIDER_BASE_URL}
REDIS__HOST=127.0.0.1
REDIS__PORT=6379
REDIS_PASSWORD=
REDIS__KEY_PREFIX=
REDIS__CACHE_INVALIDATE_URL=/cache-invalidate
REDIS__ENABLED=false
RECAPTCHA_ENABLED=true
RECAPTCHA_HIDE_BADGE=false
RECAPTCHA_VERSION=3

REDIS_ENABLED=false
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_KEY_PREFIX=
REDIS_CACHE_INVALIDATE_URL=/cache-invalidate

RECAPTCHA_ENABLED=false
RECAPTCHA_SITE_KEY=
RECAPTCHA_SECRET_KEY=
RECAPTCHA_HIDE_BADGE=
RECAPTCHA_SIZE=invisible
RECAPTCHA_MIN_SCORE=0.5
RECAPTCHA_VERSION=3
8 changes: 5 additions & 3 deletions packages/theme/middleware.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const cookieNames = require('./enums/cookieNameEnum');

const isCheckoutEnabled = process.env.MAGENTO_EXTERNAL_CHECKOUT_ENABLED === 'true',

module.exports = {
integrations: {
magento: {
Expand All @@ -11,11 +13,11 @@ module.exports = {
},
defaultStore: 'default',
externalCheckout: {
enable: process.env.MAGENTO_EXTERNAL_CHECKOUT,
enable: isCheckoutEnabled,
cmsUrl: process.env.MAGENTO_EXTERNAL_CHECKOUT_URL,
syncUrlPath: process.env.MAGENTO_EXTERNAL_CHECKOUT_SYNC_PATH,
stores: {
default: process.env.MAGENTO_EXTERNAL_CHECKOUT,
default: isCheckoutEnabled,
},
},
facets: {
Expand All @@ -28,7 +30,7 @@ module.exports = {
magentoApiEndpoint: process.env.MAGENTO_GRAPHQL,
imageProvider: process.env.IMAGAE_PROVIDER,
recaptcha: {
isEnabled: process.env.RECAPTCHA_ENABLED,
isEnabled: process.env.RECAPTCHA_ENABLED === 'true',
sitekey: process.env.RECAPTCHA_SITE_KEY,
secretkey: process.env.RECAPTCHA_SECRET_KEY,
version: process.env.RECAPTCHA_VERSION,
Expand Down
18 changes: 9 additions & 9 deletions packages/theme/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,17 @@ export default () => {
modules: [
'~/modules/catalog',
['nuxt-i18n', {
baseUrl: process.env.BASE_URL || 'http://localhost:3000',
baseUrl: process.env.STORE_URL || 'http://localhost:3000',
}],
'cookie-universal-nuxt',
'vue-scrollto/nuxt',
'@vue-storefront/middleware/nuxt',
'@nuxt/image',
['@vue-storefront/cache/nuxt', {
enabled: !!process.env.REDIS__ENABLED,
enabled: process.env.REDIS_ENABLED === 'true',
invalidation: {
endpoint: process.env.REDIS__CACHE_INVALIDATE_URL,
key: process.env.REDIS__CACHE_INVALIDATE_KEY,
endpoint: process.env.REDIS_CACHE_INVALIDATE_URL,
key: process.env.REDIS_CACHE_INVALIDATE_KEY,
handlers: [
'@vue-storefront/cache/defaultHandler',
],
Expand All @@ -116,9 +116,9 @@ export default () => {
{
// docs: https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options
redis: {
keyPrefix: process.env.REDIS__KEY_PREFIX,
host: process.env.REDIS__HOST,
port: process.env.REDIS__PORT,
keyPrefix: process.env.REDIS_KEY_PREFIX,
host: process.env.REDIS_HOST,
port: process.env.REDIS_PORT,
},
},
],
Expand Down Expand Up @@ -235,7 +235,7 @@ export default () => {
};
}

if (process.env.RECAPTCHA_ENABLED) {
if (process.env.RECAPTCHA_ENABLED === 'true') {
baseConfig.modules.push('@nuxtjs/recaptcha');

baseConfig.recaptcha = {
Expand All @@ -247,7 +247,7 @@ export default () => {

baseConfig.publicRuntimeConfig = {
...baseConfig.publicRuntimeConfig,
isRecaptcha: process.env.RECAPTCHA_ENABLED,
isRecaptcha: process.env.RECAPTCHA_ENABLED === 'true',
};
}

Expand Down

0 comments on commit a079b0e

Please sign in to comment.