# Dockerizing

## General

The services that you are building need to be packaged as Docker container images. For that, you do not need to write a `Dockerfile` or anything like that. We already have pre-defined types of Docker image packaging that you should use.

## What should I do then?

You need to ask the [DevOps](https://github.com/island-is/island.is/blob/main/handbook/technical-overview/devops/technical-overview/devops/personas.md#devops) team to create a Docker repository for you, which has the same name your service has in NX. This is an important convention to make everyone's lives easier. Then you need to manually add to your project's `project.json` file a target that describes what kind of Docker packaging it needs. For example, adding this target

```json
  "docker-next": {}
```

means your service will be packaged as a NextJS Docker container image. We have support the following types of Docker containers:

* `docker-next`: suitable for [NextJS](https://nextjs.org/) services.
* `docker-express`, suitable for [ExpressJS](https://expressjs.com) as well as [NestJS](https://nestjs.com) services.
* `docker-static`, suitable for serving all types of static content. Suitable for pure HTML or React SPAs.
* `docker-cypress`, suitable for running cypress tests in docker.
* `docker-native`, not implemented

If you would like to see some examples, simply search for "docker" in that file and you should find plenty.

When you push this change to `main` your Docker image will get built and pushed to our private central Docker registry

{% hint style="info" %}
To dockerize a NextJS project, you additionally need to configure it to use [our custom server](/development/devops/next-server.md#setup-in-new-project).
{% endhint %}

## Can I create a secret in the aws parameters store for services to consume?

Yes you can! Find out about it on the [AWS Secrets documentation](/development/aws-secrets.md).

## Troubleshooting

*Prerequisite*: Local Docker support

If you are having problems with your application running inside a Docker container, you can troubleshoot that by downloading the Docker container and running it locally on your workstation.

To do that you need to follow this process:

1. Login to our **AWS Shared account** and get command line access settings

   ![Login](/files/-ML85TCVtQMq9O7UkBh1) ![Env copy](/files/-ML85TCYK2gA2YQjdt6O)
2. Open your terminal and paste the AWS creds from the clipboard
3. Run this to authenticate to our private Docker registry

   ```
    aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin 821090935708.dkr.ecr.eu-west-1.amazonaws.com
   ```
4. Now you can poke around in the Docker container like this (Docker image and tag can be retrieved from a few places, depending on where you are starting from - Spinnaker, GitHub CI, Kubenav/Kubernetes)

   ```
    docker run --rm -it --entrypoint=sh 821090935708.dkr.ecr.eu-west-1.amazonaws.com/<image>:<tag>
   ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.devland.is/development/devops/dockerizing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
