> ## Documentation Index
> Fetch the complete documentation index at: https://ona.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure a database

Our application looks good, as we can now create events and we have a frontend and backend automatically running when we start workspaces. However, our APIs won't work yet, as they need to be configured to use a database.

With Gitpod you can connect to externally hosted databases. However, for simplicity, in this tutorial we're going to set up a database that runs in our workspace. To help installing our database we're going to use Gitpod workspace iamges.

## Understanding workspace images

When no image is referenced in the `.gitpod.yml` workspaces use the `workspace-full` image by default, which comes with many commonly used utilities. If you want to override the [workspace image](/classic/user/configure/workspaces/workspace-image) you can reference a built Docker image.

```yml .gitpod.yml theme={null}
image: registry.hub.docker.com/your_username/image
```

Or, you can reference a Dockerfile in the repository.

```yml .gitpod.yml theme={null}
image:
    file: .gitpod.Dockerfile
```

## Installing Postgres

For our example we'll use Postgres with the Gitpod [PostgresQL workspace image](https://github.com/gitpod-io/workspace-images/blob/main/chunks/tool-postgresql).

Copy the following line into your `.gitpod.yml` file:

```yml .gitpod.yml theme={null}
image: gitpod/workspace-postgres
```

The image will start postgres by default on port `5432`. Let's add a port configuration to define and ignore that port in our `.gitpod.yml`.

Again, copy the following lines into your `.gitpod.yml` file:

```yml .gitpod.yml theme={null}
 - name: database
   port: 5432
   onOpen: ignore
```

## Database seeding

Finally, let's automate the creation of our schema, and any necessary data seeding. For that, let's add our `init-db.sh` script to our `.gitpod.yml`. Copy the following into the `tasks` block that we created earlier:

```yml .gitpod.yml theme={null}
 - name: create tables in db
   command: './init-db.sh'
```

## Next Steps

[Configure environment variables →](/classic/user/introduction/gitpod-tutorial/5-use-environment-variables)
