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

Remove TypeScript code snippets from DigitalOcean deployment guide #940

Merged
merged 14 commits into from
Jun 15, 2022
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@ Prior to starting the deployment process each user needs:
Strapi uses [environment configurations](/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.md) to maintain multiple environments inside a single application. This section describes how to setup a production environment in a Strapi application.

1. Add a production configuration environment by creating a sub-directory `./config/env/production`.
2. Create `database.js` (or `database.ts` for TypeScript projects) inside the `./config/env/production` directory.
2. Create `database.js` inside the `./config/env/production` directory.
3. Add the code snippet to the `database` configuration file:

<code-group>

<code-block title='JAVASCRIPT'>

```jsx
// path: ./config/env/production/database.js

Expand All @@ -54,41 +50,9 @@ Strapi uses [environment configurations](/developer-docs/latest/setup-deployment

```

</code-block>

<code-block title='TYPESCRIPT'>

```jsx
// path: ./config/env/production/database.ts

export default ({ env }) => ({
connection: {
client: 'postgres',
connection: {
host: env('DATABASE_HOST'),
port: env.int('DATABASE_PORT'),
database: env('DATABASE_NAME'),
user: env('DATABASE_USERNAME'),
password: env('DATABASE_PASSWORD'),
ssl: {
rejectUnauthorized:env.bool('DATABASE_SSL_SELF', false),
},
},
debug: false,
},
});
```

</code-block>
</code-group>

4. Create `server.js` (or `server.ts` for TypeScript projects) inside the `./config/env/production` directory.
4. Create `server.js` inside the `./config/env/production` directory.
5. Add the code snippet to the `server` configuration file:

<code-group>

<code-block title='JAVASCRIPT'>

```jsx
// path: ./config/env/production/server.js

Expand All @@ -101,25 +65,6 @@ Strapi uses [environment configurations](/developer-docs/latest/setup-deployment
});
```

</code-block>

<code-block title='TYPESCRIPT'>

```jsx
// path: ./config/env/production/server.ts

export default ({ env }) => ({
proxy: true,
url: env('APP_URL'), // replaces `host` and `port` properties in the development environment
app: {
keys: env.array('APP_KEYS')
},
});
```

</code-block>
</code-group>

6. Add PostgreSQL dependencies by installing [`pg` package](https://www.npmjs.com/package/pg):

<code-group>
Expand Down Expand Up @@ -248,10 +193,6 @@ yarn add pg-connection-string

To switch to a managed database modify the `config/env/production/database` file to be able to parse the `DATABASE_URL`:

<code-group>

<code-block title='JAVASCRIPT'>

```jsx
// path: ./config/env/production/database.js

Expand All @@ -278,39 +219,6 @@ module.exports = ({ env }) => ({

```

</code-block>

<code-block title='TYPESCRIPT'>

```jsx
// path: ./config/env/production/database.ts

const parse = require("pg-connection-string").parse;

const { host, port, database, user, password } = parse(
process.env.DATABASE_URL
);

export default ({ env }) => ({
client: 'postgres',
connection: {
host,
port,
database,
user,
password,
ssl: {
rejectUnauthorized: false,
},
debug: false,
},
});

```

</code-block>
</code-group>

### Create a managed database on DigitalOcean

Changing the settings on the DigitalOcean App Platform to incorporate a managed database requires creating and attaching the database to an existing Strapi application. Additionally, the database environment variables must be removed, as managed databases propagate the connection properties automatically.
Expand Down