shopify-app-template-node
shopify-app-template-node copied to clipboard
Production deployment with nextjs Dockerfile
Issue summary
I'm trying to deploy my app created using this template to a k8s cluster using nextjs docker file here https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile however i'm getting this error API key must be provided I have checked the pod and it's running correctly..
Maybe this was solved but Id like to noticed:
- Your
.envfile should haveSHOPIFY_API_KEY=........ - Your
server.js:Shopify.Context.initialize({ API_KEY: process.env.SHOPIFY_API_KEY, ........ - Your
_app.js:config={{ apiKey: API_KEY, ....... - your
next.config.js:
const { parsed: localEnv } = require("dotenv").config();
const webpack = require("webpack");
const apiKey = JSON.stringify(process.env.SHOPIFY_API_KEY);
module.exports = {
webpack: (config) => {
const env = { API_KEY: apiKey };
config.plugins.push(new webpack.DefinePlugin(env));
// Add ESM support for .mjs files in webpack 4
config.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: "javascript/auto",
});
return config;
},
};
But! I was unable to deploy anywhere else other than Heroku.... so, good luck trying to use docker.........
I also faced this issue while deploying the nextjs app to a k8 cluster. The problem was that the API_KEY was not getting injected into the docker image during the build phase and thus not available to nextjs build.
So, I added the Api key to the docker image with
docker build --build-arg NEXT_PUBLIC_SHOPIFY_API_KEY=<api-key>
and then used it in the nextjs build using the docker ARG
ARG NEXT_PUBLIC_SHOPIFY_API_KEY
RUN npm run build
This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.
We are closing this issue because it has been inactive for a few months. This probably means that it is not reproducible or it has been fixed in a newer version. If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.
If you still encounter this issue with the latest stable version, please reopen using the issue template. You can also contribute directly by submitting a pull request– see the CONTRIBUTING.md file for guidelines
Thank you!