2 years ago
Are environment variables exposed during the build step? Or only the deployment?
18 Replies
I suspect that some variables are not being exposed during a build step in my docker image. I don't have a great way of tracking this down. "works on my machine" but not on railway
2 years ago
yes they are exposed as build args
hmmmmmmmmm idk. My vite builds don't seem to have the variable in them.
2 years ago
dockerfile or nixpacks?
2 years ago
send it?
FROM oven/bun:latest as build
WORKDIR /app
COPY package.json bun.lockb .
RUN bun install --frozen-lockfile
COPY . .
RUN bun run build
FROM caddy:latest
copy --from=build /app/dist /dist/
COPY Caddyfile /etc/caddy/Caddyfile
RUN caddy fmt --overwrite /etc/caddy/Caddyfile
CMD exec caddy run --config /etc/caddy/Caddyfile --adapter caddyfile 2>&12 years ago
theres no build args there
Yea. I wouldn't normally need it. Just not used to the way Vite handles environement variables. But I guess just some ARG VITE_NAME_OF_THING should be good
2 years ago
FROM oven/bun:latest AS build
WORKDIR /app
COPY package.json bun.lockb .
RUN bun install --frozen-lockfile
COPY . ./
ARG VITE_BACKEND_URL
RUN bun run build
FROM caddy:latest
WORKDIR /app
copy --from=build /app/dist ./dist/
COPY Caddyfile /etc/caddy/Caddyfile
RUN caddy fmt --overwrite /etc/caddy/Caddyfile
CMD exec caddy run --config /etc/caddy/Caddyfile --adapter caddyfile 2>&12 years ago
you absolutely do need them haha, if you want to use variables during build
Yea, let me go try that. I hope it fixes my issue.
Finally getting around to fixing it from all that time ago
Yay!!! It actually works now!! Now when a user reports a bug I can spy on them to find out if it was human error or a me error. Thanks posthog
2 years ago
lmao
jk about the spying. Well … kinda. It is sessions. I can see what they did. Great feature
That is what made me prioritize coming back to this. A user complained about a bug that in my mind is actually impossible. But I can't tell them that. So now we wait for them to report it again … and I see if it really is a bug ….
2 years ago
A user complained about a bug that in my mind is actually impossible. But I can't tell them that
story of my life