S
SolidJS•3w ago
MaveriX89

Containerized Solid Start Deployments

I'm new to using Solid Start and full-stack frameworks -- I usually create "vanilla" app architectures (e.g. a Solidjs SPA paired with an Elysia backend-for-frontend layer). With those vanilla setups, I could containerize the deployments using Dockerfiles and reason about them very easily. However, for Solid Start, I'm not sure how to reason about them fully because there are gaps in my knowledge. The intent I have is to create a containerized Solid Start deployment that I could run anywhere (Azure, AWS, GCP, etc.). In my app, I am using a database (SQLite + Drizzle ORM) and Better Auth for authentication/authorization (it adds tables to the database mentioned earlier). I would also like to use Bun for my runtime -- unsure if this is a wise-decision if Bun isn't supported fully across hosting providers. I had the following Dockerfile but unfortunately it does not work as the docker build chokes when attempting to install the better-sqlite3 dependency I have in my project:
FROM oven/bun:1.1.42-alpine

WORKDIR /app

COPY package.json bun.lock ./
RUN bun install --frozen-lockfile

COPY public ./public
COPY tsconfig.json ./
COPY app.config.ts ./
COPY drizzle ./drizzle
COPY src ./src

RUN bun run build

EXPOSE 3000

CMD ["bun", "start"]
FROM oven/bun:1.1.42-alpine

WORKDIR /app

COPY package.json bun.lock ./
RUN bun install --frozen-lockfile

COPY public ./public
COPY tsconfig.json ./
COPY app.config.ts ./
COPY drizzle ./drizzle
COPY src ./src

RUN bun run build

EXPOSE 3000

CMD ["bun", "start"]
I suspect it has something to do with the base Bun image I'm using, but I went and used the full oven/bun base image and that still did not resolve the install block on better-sqlite3. Hoping someone with more experience in this arena can assist or guide my thinking so that I can better understand how to work through these kinds of problems. Thanks for any help in advance! P.S. I feel like this is a great opportunity to perhaps update the Solid Start documentation to include a section on Deployments and what that looks like if people want to pursue the whole "build once and deploy anywhere" mantra. That may be a pipe dream because I'm sure there are a lot of fancy things going on under the hood that may make that hard to generalize, but just a thought that I had and wanted to share here. 🙂
1 Reply
MaveriX89
MaveriX89OP•3w ago
Ah, I made some progres and managed to successfully create a Docker image using the following:
FROM imbios/bun-node:1.1.42-22-slim

WORKDIR /app

COPY package.json bun.lock ./
RUN bun install --frozen-lockfile

COPY public ./public
COPY tsconfig.json ./
COPY app.config.ts ./
COPY drizzle ./drizzle
COPY src ./src

RUN bun run build

EXPOSE 3000

CMD ["bun", "start"]
FROM imbios/bun-node:1.1.42-22-slim

WORKDIR /app

COPY package.json bun.lock ./
RUN bun install --frozen-lockfile

COPY public ./public
COPY tsconfig.json ./
COPY app.config.ts ./
COPY drizzle ./drizzle
COPY src ./src

RUN bun run build

EXPOSE 3000

CMD ["bun", "start"]
Guess we're not really using bun as the underlying runtime because the Vinxi server uses Node if I'm not mistaken (but I'm using bun to run scripts and manage my dependencies). So I use the imbios/bun-node:1.1.42-22-slim base image (alpine did not work).

Did you find this page helpful?