---
# System prepended metadata

title: Nomsters Documentation

---

# Nomsters Documentation

###### tags: learn

## **Docker**


---

### Adding a Service

When adding a service (such as backend or database), changes need to be made to the `docker-compose.yml` file, located in the root of our project. 

For example, if adding Prisma, our additional services may look like this: 

![Prisma Services Configuration for Docker](https://i.imgur.com/94vNKDK.png)

- The `links` and `depends_on` refers to the dependancy that Prisma has on MySQL in this particular case, but whatever database we use (which we will also add as a service will be put into `depends_on`.

- Prisma, or any other service we may add, will have its own `container_name`, as well as its own folder and file directory within the root of our project (**see Frontend folder for an example**)
- We will also need to add a `Dockerfile` in each service directory folder. An example for what the `Dockerfile` may look like for Prisma is shown below:

![Prisma Dockerfile configuration](https://i.imgur.com/eE8hkYj.png)

#### [Detailed Documentation on how to compose a Dockerfile can be found here](https://docs.docker.com/compose/compose-file/)

## Docker Defintions

- volumes
    - Creates a mapping between physical machine code and container working directory code
- services
    - How many services we want to run
- Dockerfile
    - A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image
- depends_on
    - Indicate what this services uses
- Image 
    - A Docker image is a read-only template that contains a set of instructions for creating a container that can run on the Docker platform. It provides a convenient way to package up applications and preconfigured server environments, which you can use for your own private use or share publicly with other Docker users.
- build
    - The docker build command builds Docker images from a Dockerfile and a “context”. A build’s context is the set of files located in the specified PATH or URL

---

 ## **Next.js + Serverless**

### Creating a new Next.js project:

- In your terminal, enter `yarn create next-app`
- Enter project name
- cd into directory
- to install dev dependencies: `yarn add serverless-next.js -D`

Configure Next Project to deploy to a serverless environment:

- go to top of directory and create a file called `next.config.js`
    - open file and enter the following:

            module.exports = {
                target: "serverless"
            }

### Serverless Component Configuration


**Set up AWS environment variables:**

- create .env file
    - enter AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
- create serverless.yml file and enter the following configuration text:

      nextApp:  
          component:"serverless-next.js"
    
**Deploy Project to AWS Environment**

- In terminal:`yarn serverless`

This command Deploys our Cloudfront distribution and creates an s3 bucket and configuring everything together so we can have a serverside rendered application with Next.js along with status components of the application hosted inside of s3 static hosting and forwarded to from Cloudfront

Once the project is deploued, an app url is provided. Click on the link to see deployed project. If receiving a "This site can't be reached error", this means that the Cloudfront distribution process is not yet complete and the DNS has not properly propagated. This can take up to 30 minutes, and subsequent deploys happen much more quickly. Deployment status can also be viewed on your AWS dashboard.



