a year ago
Each build takes roughly like 4 minutes. I'm testing on prod so it makes my iterations kinda slow.
0 Replies
```FROM oven/bun:1 as base
WORKDIR /usr/src/app
RUN apt update \
&& apt install -y curl
ARG NODEVERSION=18 RUN curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n \ && bash n $NODEVERSION \
&& rm n \
&& npm install -g n
COPY . .
ARG DATABASE_URL
RUN bun install --frozen-lockfile
RUN bunx turbo run db:generate
RUN bun build --compile --minify ./apps/server/index.ts --outfile server
ENV NODE_ENV=production
CMD ./server
```
a year ago
how big is the image?
a year ago
also why compile and minify your .ts file? bun has first class support for ts
a year ago
how long does that specific command take when building?
a year ago
how long does railway say it took
a year ago
yes, how big
a year ago
keep in mind i cant read your logs for you
a year ago
thats big, do you need node during the runtime?
not after i've compiled the executable from bun, i don't think i need anything at that point
a year ago
big images take a seemingly exponentially longer time to deploy and there is some awsome fixes in the pipeline for that
a year ago
but until then, the only fix would be to write a better dockerfile
```FROM oven/bun:1 as base
WORKDIR /usr/src/app
RUN apt update \
&& apt install -y curl
ARG NODEVERSION=18 RUN curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n \ && bash n $NODEVERSION \
&& rm n \
&& npm install -g n
COPY . .
ARG DATABASE_URL
RUN bun install --frozen-lockfile
RUN bunx turbo run db:generate
RUN bun build --compile --minify ./apps/server/index.ts --outfile server
// TODO erase everything else
ENV NODE_ENV=production
CMD ./server
```
a year ago
in more words, yes, you will want to look into multi layered images
a year ago
you are like 10% of the way there with -
FROM oven/bun:1 as base
a year ago
nope, please look into multi layered dockerfiles
a year ago
FROM oven/bun:1 AS builder
// install node and do build stuff
FROM oven/bun:1
// only copy the needed stuff down
// start the server
a year ago
get the idea?
while i agree that will help, I don't think that solves the core issue
i think the biggest time sink is that the 700mb executable is being uploaded every time
a year ago
are we talking about the node executable?
a year ago
its actually 700mb?? where is this number coming from?
no the compiled executable is only 70mb, idk where the rest is coming from
a year ago
then it's coming from node and everything else in the image that isn't needed
a year ago
^
a year ago
^