Develop locally with Strapi v3
Try Upsun for 15 days
After that, enjoy the same game-changing Upsun features for less with the First Project Incentive!¹ A monthly $19 perk!
¹Terms and conditions apply. Only for Flexible Resource projects.
You can run your Strapi v3 app locally with all of its services.
First install the config reader by running the following command:
npm install platformsh-config OR yarn add platformsh-configIt’s also assumed that your database.js file in your config folder looks like this:
const config = require("platformsh-config").config();
let dbRelationship = "postgresdatabase";
// Strapi default sqlite settings.
let settings = {
client: "sqlite",
filename: process.env.DATABASE_FILENAME || ".tmp/data.db",
};
let options = {
useNullAsDefault: true,
};
if (config.isValidPlatform() && !config.inBuild()) {
// Upsun Fixed database configuration.
const credentials = config.credentials(dbRelationship);
console.log(
`Using Upsun Fixed configuration with relationship ${dbRelationship}.`
);
settings = {
client: "postgres",
host: credentials.ip,
port: credentials.port,
database: credentials.path,
username: credentials.username,
password: credentials.password,
};
options = {
ssl: false,
debug: false,
acquireConnectionTimeout: 100000,
pool: {
min: 0,
max: 10,
createTimeoutMillis: 30000,
acquireTimeoutMillis: 600000,
idleTimeoutMillis: 20000,
reapIntervalMillis: 20000,
createRetryIntervalMillis: 200,
},
};
} else {
if (config.isValidPlatform()) {
// Build hook configuration message.
console.log(
"Using default configuration during Upsun Fixed build hook until relationships are available."
);
} else {
// Strapi default local configuration.
console.log(
"Not in an Upsun Fixed Environment. Using default local sqlite configuration."
);
}
}
module.exports = {
defaultConnection: "default",
connections: {
default: {
connector: "bookshelf",
settings: settings,
options: options,
},
},
};If it’s similar to the above and you’re running a Strapi v3 application, follow the instructions for general local development.