mta.coder97
mta.coder97
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
I am in need of help in regards to deploying a react + vite app to railway. So I have a dockerfile for my app which i've told railway the path to the dockerfile to deploy the app. The issue is that from what I've gathered, railway doesn't inject the ENV variables during the build process and vite relies on that as it takes ENV variables then replaces the values in the code during the build process. Is there a way of passing ARG variables as an alternative in railway to my dockerfile? Or what would be the solution for me to be able to use the ENV variables during the build process so that Vite has access to the ENV variables to inject into the code? Just for some context this is a bit of the code in the dockerfile that I'm referring to:
# Install doppler and provide the doppler token so the ENV variables can be statically replaced in the react+vite app.
RUN wget -q -t3 'https://packages.doppler.com/public/cli/rsa.8004D9FF50437357.key' -O /etc/apk/keys/[email protected]
RUN echo 'https://packages.doppler.com/public/cli/alpine/any-version/main' | tee -a /etc/apk/repositories
RUN apk add doppler

ENV DOPPLER_TOKEN=${DOPPLER_TOKEN}

COPY --from=builder /app/out/full/ ./
COPY turbo.json turbo.json
RUN yarn turbo run build --filter=webapp...
# Install doppler and provide the doppler token so the ENV variables can be statically replaced in the react+vite app.
RUN wget -q -t3 'https://packages.doppler.com/public/cli/rsa.8004D9FF50437357.key' -O /etc/apk/keys/[email protected]
RUN echo 'https://packages.doppler.com/public/cli/alpine/any-version/main' | tee -a /etc/apk/repositories
RUN apk add doppler

ENV DOPPLER_TOKEN=${DOPPLER_TOKEN}

COPY --from=builder /app/out/full/ ./
COPY turbo.json turbo.json
RUN yarn turbo run build --filter=webapp...
34 replies