Eduardo Ruesta
05/28/2024, 3:28 PMException in thread "main" com.varabyte.kobweb.common.error.KobwebException: No site folder found. Did you runAnd this is my Dockerfile (first time with Docker):?kobweb export
#-----------------------------------------------------------------------------
# Variables shared across multiple stages (they need to be explicitly opted
# into each stage by being declaring there too, but their values need only be
# specified once).
ARG KOBWEB_APP_ROOT="site"
FROM eclipse-temurin:17 as java
FROM java as export
#-----------------------------------------------------------------------------
# Create an intermediate stage which builds and exports our site. In the
# final stage, we'll only extract what we need from this stage, saving a lot
# of space.
ENV KOBWEB_CLI_VERSION=0.9.13
ARG KOBWEB_APP_ROOT
ENV NODE_MAJOR=20
# Copy the project code to an arbitrary subdir so we can install stuff in the
# Docker container root without worrying about clobbering project files.
COPY . /project
# Update and install required OS packages to continue
# Note: Node install instructions from: <https://github.com/nodesource/distributions#installation-instructions>
# Note: Playwright is a system for running browsers, and here we use it to
# install Chromium.
RUN apt-get update \
&& apt-get install -y ca-certificates curl gnupg unzip wget \
&& mkdir -p /etc/apt/keyrings \
&& curl -fsSL <https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key> | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] <https://deb.nodesource.com/node_$NODE_MAJOR.x> nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get install -y nodejs \
&& npm init -y \
&& npx playwright install --with-deps chromium
# Fetch the latest version of the Kobweb CLI
RUN wget <https://github.com/varabyte/kobweb-cli/releases/download/v${KOBWEB_CLI_VERSION}/kobweb-${KOBWEB_CLI_VERSION}.zip> \
&& unzip kobweb-${KOBWEB_CLI_VERSION}.zip \
&& rm kobweb-${KOBWEB_CLI_VERSION}.zip
ENV PATH="/kobweb-${KOBWEB_CLI_VERSION}/bin:${PATH}"
WORKDIR /project/${KOBWEB_APP_ROOT}
# Decrease Gradle memory usage to avoid OOM situations in tight environments
# (many free Cloud tiers only give you 512M of RAM). The following amount
# should be more than enough to build and export our site.
RUN mkdir ~/.gradle && \
echo "org.gradle.jvmargs=-Xmx256m" >> ~/.gradle/gradle.properties
RUN kobweb export --notty
#-----------------------------------------------------------------------------
# Create the final stage, which contains just enough bits to run the Kobweb
# server.
FROM java as run
ARG KOBWEB_APP_ROOT
COPY --from=export /project/${KOBWEB_APP_ROOT}/.kobweb .kobweb
ENTRYPOINT .kobweb/server/start.sh
Any idea which could be the issue? Thanksjeff
05/28/2024, 5:16 PM--progress=plain
and looking for the failureEduardo Ruesta
05/28/2024, 5:47 PMjeff
05/28/2024, 6:06 PMdocker build --progress plain -t <TAG_NAME> .
(tag name is arbitrary, just pick an identifier)Eduardo Ruesta
05/29/2024, 2:40 PMException in thread "main" java.lang.NullPointerException: getenv(...) must not be null
May 29 111913 AM at com.exxample.kobweb.data.MongoDB.<init>(MongoDB.kt:36)
May 29 111913 AM at com.exxample.kobweb.data.MongoDBKt.initMongoDB(MongoDB.kt:
jeff
05/29/2024, 2:42 PMEduardo Ruesta
05/29/2024, 2:43 PMMongoClient.create(System.getenv("MONGODB_URI"))
the same onejeff
05/29/2024, 2:46 PMEduardo Ruesta
05/29/2024, 2:47 PMjeff
05/29/2024, 2:51 PMjeff
05/29/2024, 2:51 PMEduardo Ruesta
05/29/2024, 2:52 PM@InitApi
fun initMongoDB(ctx: InitApiContext) {
System.setProperty(
"org.litote.mongo.test.mapping.service",
"org.litote.kmongo.serialization.SerializationClassMappingTypeService"
)
ctx.data.add(MongoDB(ctx))
}
class MongoDB(private val context: InitApiContext) : MongoRepository {
private val client = MongoClient.create(System.getenv("MONGODB_URI"))
private val database = client.getDatabase(DATABASE_NAME)
private val userCollection = database.getCollection<User>("user")
private val postCollection = database.getCollection<Post>("post")
....
....
jeff
05/29/2024, 2:54 PMEduardo Ruesta
05/29/2024, 3:00 PMEduardo Ruesta
05/29/2024, 3:00 PMjeff
05/29/2024, 3:03 PMkobweb export
has a step where it renders all your pages (for SEO reasons) -- see the thread I linked originally
3. In order to do that rendering, it spins up your server
4. But at this stage, your env var isn't set, hence the crashjeff
05/29/2024, 3:05 PMjeff
05/29/2024, 3:08 PMEduardo Ruesta
05/29/2024, 3:12 PMEduardo Ruesta
05/29/2024, 3:12 PMEduardo Ruesta
05/29/2024, 3:27 PMEduardo Ruesta
05/30/2024, 12:20 PMdelay mongo initialization, so that it doesn't trigger as part of the export
how can i do this?Phuc
12/19/2024, 5:18 AMException in thread âmainâ com.varabyte.kobweb.common.error.KobwebException: No site folder found. Did you run?kobweb export
Phuc
12/19/2024, 5:18 AMEduardo Ruesta
12/19/2024, 1:23 PMPhuc
12/19/2024, 1:25 PMâException in thread âmainâ com.varabyte.kobweb.common.error.KobwebException: No site folder found. Did you run?kobweb export
Phuc
12/19/2024, 1:26 PMPhuc
12/19/2024, 1:26 PMEduardo Ruesta
12/19/2024, 1:27 PMPhuc
12/19/2024, 1:28 PMRUN mkdir ~/.gradle && \
echo "org.gradle.jvmargs=-Xmx300m" >> ~/.gradle/gradle.properties
Phuc
12/19/2024, 1:28 PMEduardo Ruesta
12/19/2024, 1:31 PMEduardo Ruesta
12/19/2024, 1:32 PM#-----------------------------------------------------------------------------
# Variables are shared across multiple stages (they need to be explicitly
# opted into each stage by being declaring there too, but their values need
# only be specified once).
ARG KOBWEB_APP_ROOT="site"
# ^ NOTE: Kobweb apps generally live in a root "site" folder in your project,
# but you can change this in case your project has a custom layout.
FROM eclipse-temurin:17 as java
#-----------------------------------------------------------------------------
# Create an intermediate stage which builds and exports our site. In the
# final stage, we'll only extract what we need from this stage, saving a lot
# of space.
FROM java as export
ENV KOBWEB_CLI_VERSION=0.9.15
ARG KOBWEB_APP_ROOT
ENV NODE_MAJOR=20
# Copy the project code to an arbitrary subdir so we can install stuff in the
# Docker container root without worrying about clobbering project files.
COPY . /project
# Update and install required OS packages to continue
# Note: Node install instructions from: <https://github.com/nodesource/distributions#installation-instructions>
# Note: Playwright is a system for running browsers, and here we use it to
# install Chromium.
RUN apt-get update \
&& apt-get install -y ca-certificates curl gnupg unzip wget \
&& mkdir -p /etc/apt/keyrings \
&& curl -fsSL <https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key> | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] <https://deb.nodesource.com/node_$NODE_MAJOR.x> nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get install -y nodejs \
&& npm init -y \
&& npx playwright install --with-deps chromium
# Fetch the latest version of the Kobweb CLI
RUN wget <https://github.com/varabyte/kobweb-cli/releases/download/v${KOBWEB_CLI_VERSION}/kobweb-${KOBWEB_CLI_VERSION}.zip> \
&& unzip kobweb-${KOBWEB_CLI_VERSION}.zip \
&& rm kobweb-${KOBWEB_CLI_VERSION}.zip
ENV PATH="/kobweb-${KOBWEB_CLI_VERSION}/bin:${PATH}"
WORKDIR /project/${KOBWEB_APP_ROOT}
# Decrease Gradle memory usage to avoid OOM situations in tight environments
# (many free Cloud tiers only give you 512M of RAM). The following amount
# should be more than enough to build and export our site.
RUN mkdir ~/.gradle && \
echo "org.gradle.jvmargs=-Xmx4096m" >> ~/.gradle/gradle.properties
RUN kobweb export --notty
#-----------------------------------------------------------------------------
# Create the final stage, which contains just enough bits to run the Kobweb
# server.
FROM java as run
ARG KOBWEB_APP_ROOT
COPY --from=export /project/${KOBWEB_APP_ROOT}/.kobweb .kobweb
ENTRYPOINT .kobweb/server/start.sh
Phuc
12/19/2024, 1:33 PMPhuc
12/19/2024, 1:33 PMPhuc
12/19/2024, 1:33 PMPhuc
12/19/2024, 1:33 PMEduardo Ruesta
12/19/2024, 1:34 PM