# Go Live!

## A few things before you go live:

### Launching to fly.io:

Fly seems to be the easiest and cheapest option for phoenix apps, so that's what we'll use for our guide.

If you haven't already, download the [Fly.io CLI](https://fly.io/docs/getting-started/installing-flyctl). Then you will need to [register or sign in](https://fly.io/docs/getting-started/log-in-to-fly/).

Create a new project by running this command:

```
flyctl launch
```

Follow the steps in the CLI, usually the default setup it best, unless you want to change the name of the project.

At this point, it will try to generate and deploy the app, but may fail. We need to make some changes for the launch to succeed. Run this command and follow the next steps.

```elixir
mix phx.gen.release --docker
```

### Add NPM &  Nodejs for js package DaisyUI to Dockerfile:

Add this code after the install build dependencies command, and above the **WORKDIR /app** command.

```docker
# Install Node.js and npm
RUN apt-get update -y && \
    apt-get install -y curl gnupg && \
    curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor -o /usr/share/keyrings/nodesource.gpg && \
    echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x bullseye main" > /etc/apt/sources.list.d/nodesource.list && \
    apt-get update -y && \
    apt-get install -y nodejs

```

Then add this below the **COPY assets assets** command:

```dockerfile
RUN npm install --prefix assets/
```

Then below this line:&#x20;

```dockerfile
COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/phx_saas ./
```

&#x20;**Copy the following:**&#x20;

```dockerfile
# Install dos2unix to fix CRLF line endings
RUN apt-get update && apt-get install -y dos2unix

# Convert all .sh files to use LF line endings
RUN find /app -type f -name "*.sh" -exec dos2unix {} +

# Ensure /app/bin/migrate and other scripts are executable
RUN chmod +x /app/bin/migrate
```

This is to ensure proper line endings. (We have run into deployment problems many times due to this)

### Re-deploy App:

Run the command below to successfully deploy your new app.

```
flyctl deploy
```

### Add your production .env variables to envs/.env.prod

Change your Canonical url to your host domain eg. "domain.com" in config.ex & root.html.heex.

And you're set!&#x20;


---

# 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.fastphoenix.pro/getting-started/go-live.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.
