a year ago
Attempting to deploy Astro app via Railway and seems like no ENV vars are being exposed.
Dockerfile as requested by <@539512869780455445>
FROM node:18.16 AS base
WORKDIR /app
COPY package.json package-lock.json ./
FROM base AS build
RUN npm ci
COPY . .
RUN npm run build
FROM base AS runtime
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/dist ./dist
# Move the drizzle directory to the runtime image
COPY --from=build /app/drizzle ./drizzle
# Create the data directory for the database
RUN mkdir -p /data
ENV HOST=0.0.0.0
ENV PORT=4321
ENV NODE_ENV=production
EXPOSE 4321
CMD node ./dist/server/entry.mjs
0 Replies
a year ago
interesting dockerfile
a year ago
please read this docs page -
a year ago
if that works, then we can move on to optimizing the dockerfile
a year ago
but show me what changes you make to the dockerfile before trying another deployment please
a year ago
correct, but still send the dockerfile before deployment please
FROM node:18.16 AS base
WORKDIR /app
ARG RAILWAY_ENVIRONMENT
ARG NODE_ENV
ARG GOOGLE_CLIENT_ID
ARG PUBLIC_GOOGLE_CLIENT_ID
ARG GOOGLE_CLIENT_SECRET
ARG AUTH_SECRET
ARG AUTH_TRUST_HOST
ARG TRIGGER_API_KEY
ARG TRIGGER_API_URL
ARG TRIGGER_PUBLIC_API_KEY
ARG URL
ARG TURSO_AUTH_TOKEN
ARG TURSO_CONNECTION_URL
COPY package.json package-lock.json ./
FROM base AS build
RUN npm ci
COPY . .
RUN npm run build
FROM base AS runtime
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/dist ./dist
# Move the drizzle directory to the runtime image
COPY --from=build /app/drizzle ./drizzle
# Create the data directory for the database
RUN mkdir -p /data
ENV HOST=0.0.0.0
ENV PORT=4321
ENV NODE_ENV=production
EXPOSE 4321
CMD node ./dist/server/entry.mjs
docker
a year ago
nope
a year ago
haha exactly what I thought you'd do
I was looking at one of your other responses, don't see much of a difference. What are you seeing?
a year ago
FROM node:18.16 AS build
WORKDIR /app
ARG RAILWAY_ENVIRONMENT
ARG NODE_ENV
ARG GOOGLE_CLIENT_ID
ARG PUBLIC_GOOGLE_CLIENT_ID
ARG GOOGLE_CLIENT_SECRET
ARG AUTH_SECRET
ARG AUTH_TRUST_HOST
ARG TRIGGER_API_KEY
ARG TRIGGER_API_URL
ARG TRIGGER_PUBLIC_API_KEY
ARG URL
ARG TURSO_AUTH_TOKEN
ARG TURSO_CONNECTION_URL
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:18.16
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/dist ./dist
# Move the drizzle directory to the runtime image
COPY --from=build /app/drizzle ./drizzle
# Create the data directory for the database
RUN mkdir -p /data
ENV HOST=0.0.0.0
ENV NODE_ENV=production
CMD ["node", "./dist/server/entry.mjs"]
Status changed to Solved railway[bot] • about 1 year ago
a year ago
hopefully there's no typos, edited on mobile
Hmm, ok so just cleaning it up a little? Seemed tow ork otherwise. Lemme try this though
a year ago
you had your layers in a weird order
Invalid define value (must be an entity name or valid JSON syntax): libsql://sderkaderka.turso.io
a year ago
how have you defined it in your railway service variables
TURSOCONNECTIONURL=libsql://fesfesfsef.turso.io
a year ago
and what's the correct syntax?
(localhost, rather)
Hmm. Might be a VITE bundle thing, I'll try adding quotes I guess. EDIT: Probably what happens when you use ARG in Dockerfile
Just tripped on the URL environment variables. adding quotes allowed it to build.
a year ago
railway strips quotes from environment variables fwiw
Adding ARGS in the Dockerfile + quotes around necessary ENV vars seemed to do it.
For anyone looking for this in the future, still not sure if I needed to update my astro.config.mjs with vite define variables, but we'll see.
a year ago
lets see your final dockerfile?
a year ago
interesting
a year ago
^
Maybe because I’m injecting them from docker it’s pulling the value before it’s stripped.
a year ago
haha not how it works
I also hook into vite to define the variables in my config file, referencing process.env so maybe that’s it too.
a year ago
we may never know