<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to deploy NextJs app via cloudron to the subdomain?]]></title><description><![CDATA[<p dir="auto">I have NextJs application wich is built to fetch data from directus backend app via API the NextJs app is working fine on my local machine. I need to delivery that app to the subdomain using cloudron service to be hosted on my Ubuntu AWS Lightsail instance.</p>
<p dir="auto">Please help me how to achieve that? I can't understand if it could be done using the repository: <code>https://git.cloudron.io/cloudron/tutorial-typescript-app</code></p>
<p dir="auto">Any help or advice would be highly appreciated</p>
]]></description><link>https://forum.cloudron.io/topic/11501/how-to-deploy-nextjs-app-via-cloudron-to-the-subdomain</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 05:44:58 GMT</lastBuildDate><atom:link href="https://forum.cloudron.io/topic/11501.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 08 Apr 2024 14:22:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to deploy NextJs app via cloudron to the subdomain? on Tue, 09 Apr 2024 21:33:35 GMT]]></title><description><![CDATA[<p dir="auto">So here's a little sum up how I do it:</p>
<ol>
<li>Create dockerfile</li>
</ol>
<pre><code>ARG nodeversion=21-bullseye

# build stage using standard node container
FROM docker.io/node:$nodeversion AS builder

WORKDIR /app

# copy &amp; install dependencies
COPY package.json yarn.lock .yarnrc.yml ./
COPY .yarn/ .yarn
RUN yarn install
# copy source code &amp; build
COPY . .
ENV NODE_ENV=production
RUN yarn build --standalone 

# use cloudron base image for running the app
FROM docker.io/cloudron/base:4.0.0@sha256:31b195ed0662bdb06a6e8a5ddbedb6f191ce92e8bee04c03fb02dd4e9d0286df

WORKDIR /app
ENV NODE_ENV=production

# copy built files
COPY --from=builder ./app/.output ./.output/
# start script for execution of the app, make sure its executable
COPY --from=builder ./app/start.sh ./
RUN chmod +x /app/start.sh

# set the port and host and expose the port
ENV HOST 0.0.0.0
ENV PORT 8000
EXPOSE 8000

# start the app using start script
CMD [ "/app/start.sh"]
</code></pre>
<ol start="2">
<li>Create <a href="http://start.sh" target="_blank" rel="noopener noreferrer nofollow ugc">start.sh</a></li>
</ol>
<pre><code>#!/bin/bash

set -eu

# set any environment variables here, e.g. database connection details

# run the server
node .output/server/index.mjs
</code></pre>
<ol start="3">
<li>Create CloudronManifest.json<br />
Nothing special here, follow <a href="https://docs.cloudron.io/packaging/manifest/" target="_blank" rel="noopener noreferrer nofollow ugc">documentation from Cloudron</a>, set app details, add addons, set exposed port, etc.</li>
<li>Create CI/CD pipeline<br />
This depends a bit on your runner setup, I'm using a custom gitlab runner package on Cloudron I build for myself + the cloudron build service app. This has some quirks but works for me. Its a docker in docker runner but without access to the docker.sock its not possible to run docker commands itself (or at least didn't figure out how). Normally you'd need access to the docker.sock which is not possible with app packages and a security risk.<br />
Nevertheless here's a sample of my .gitlab-ci.yml</li>
</ol>
<pre><code>stages:
  - stage

deploy_stage:
  stage: stage
  image: node:19
  environment:
    name: STAGE
  variables:
    BUILD_SERVICE: 'https://builderbot.serverdomain.de'
    FQ_IMAGE_NAME: 'docker.serverdomain.de/imagepath'
    TAG: pre
  only:
    - main
  script:
    - npm install -g cloudron
    - cloudron build --tag $TAG --set-build-service $BUILD_SERVICE --set-repository $FQ_IMAGE_NAME --build-service-token $CI_BUILD_SERVICE_TOKEN
    - cloudron update --server my.serverdomain.de --token $CI_CLOUDRON_TOKEN --app appsubdomain.serverdomain.de --image docker.serverdomain.de/imagepath:$TAG
    #- cloudron install --server my.serverdomain.de --token $CI_CLOUDRON_TOKEN --location appsubdomain.serverdomain.de --image docker.serverdomain.de/imagepath:$TAG
</code></pre>
<p dir="auto">For first run you need to use install cli cmd and afterwards update. Hence I always keep it commented out in the pipeline in case I need to reinstall the app from scratch. A combined command for this would be brilliant *hint *hint <a class="plugin-mentions-user plugin-mentions-a" href="/user/girish" aria-label="Profile: girish">@<bdi>girish</bdi></a> <img src="https://forum.cloudron.io/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=223f9defb2f" class="not-responsive emoji emoji-android emoji--wink" style="height:23px;width:auto;vertical-align:middle" title=";)" alt="😉" /></p>
<p dir="auto">Apart from that there's a little more to it in terms of one time setup which I ommited:</p>
<ul>
<li>Setup private docker registry in Cloudron (alternative use a public registry)</li>
<li>Register the gitlab runner in gitlab</li>
<li>Setup secrets in gitlab, e.g. Cloudron access tokens</li>
<li>might be more I've forgotten, as always once setup things get blurry in memory <img src="https://forum.cloudron.io/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=223f9defb2f" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></li>
</ul>
]]></description><link>https://forum.cloudron.io/post/86685</link><guid isPermaLink="true">https://forum.cloudron.io/post/86685</guid><dc:creator><![CDATA[klawitterb]]></dc:creator><pubDate>Tue, 09 Apr 2024 21:33:35 GMT</pubDate></item><item><title><![CDATA[Reply to How to deploy NextJs app via cloudron to the subdomain? on Tue, 09 Apr 2024 14:23:39 GMT]]></title><description><![CDATA[<p dir="auto">My code might be a bit to specific for my way of doing it, but I can try to give more details when I find the time.</p>
]]></description><link>https://forum.cloudron.io/post/86674</link><guid isPermaLink="true">https://forum.cloudron.io/post/86674</guid><dc:creator><![CDATA[klawitterb]]></dc:creator><pubDate>Tue, 09 Apr 2024 14:23:39 GMT</pubDate></item><item><title><![CDATA[Reply to How to deploy NextJs app via cloudron to the subdomain? on Mon, 08 Apr 2024 18:15:10 GMT]]></title><description><![CDATA[<p dir="auto">I was able to deploy with cloudron my <code>nextjs frontend app</code> fetching <code>my directus backend via API</code> here is the repository with STEP-BY-STEP guide: <a href="https://github.com/alexmazaltov/nextjs-app-for-directus-vai-cloudron" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/alexmazaltov/nextjs-app-for-directus-vai-cloudron</a></p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/klawitterb" aria-label="Profile: klawitterb">@<bdi>klawitterb</bdi></a> May i ask you to share your code?</p>
]]></description><link>https://forum.cloudron.io/post/86620</link><guid isPermaLink="true">https://forum.cloudron.io/post/86620</guid><dc:creator><![CDATA[Oleksii909]]></dc:creator><pubDate>Mon, 08 Apr 2024 18:15:10 GMT</pubDate></item><item><title><![CDATA[Reply to How to deploy NextJs app via cloudron to the subdomain? on Mon, 08 Apr 2024 17:18:45 GMT]]></title><description><![CDATA[<p dir="auto">I’m building a nuxt.js app myself (same as next but for vue). I find it relatively easy to build a custom docker image for cloudron. Using gitlab + gitlab runner on cloudron to build the app and push a docker image to the internal docker registry and deploy it from there to cloudron. Even got 2 versions of the app running for some test staging.</p>
]]></description><link>https://forum.cloudron.io/post/86618</link><guid isPermaLink="true">https://forum.cloudron.io/post/86618</guid><dc:creator><![CDATA[klawitterb]]></dc:creator><pubDate>Mon, 08 Apr 2024 17:18:45 GMT</pubDate></item><item><title><![CDATA[Reply to How to deploy NextJs app via cloudron to the subdomain? on Mon, 08 Apr 2024 15:29:04 GMT]]></title><description><![CDATA[<p dir="auto">Currently there is no deployment endpoint of any kind for specific frameworks like nextjs. For such cases you would have to build a custom app package <a href="https://docs.cloudron.io/packaging/tutorial/" target="_blank" rel="noopener noreferrer nofollow ugc">https://docs.cloudron.io/packaging/tutorial/</a></p>
<p dir="auto">We have thought of maybe providing an app, which could act as a nextjs deployment endpoint, however this is not our main focus to be a developer/deployment platform.</p>
<p dir="auto">But would be great if others here could contribute if it would be generally useful to add and also what the expectations for this feature would be.</p>
]]></description><link>https://forum.cloudron.io/post/86613</link><guid isPermaLink="true">https://forum.cloudron.io/post/86613</guid><dc:creator><![CDATA[nebulon]]></dc:creator><pubDate>Mon, 08 Apr 2024 15:29:04 GMT</pubDate></item></channel></rss>