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
Thank you so much @Brody , really appreciate the very quick responses and help 👍
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
i set nginx to listen on 3000 since my react app listens on 3000 so lets see if this works
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
deployment in progress right now
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
ahh i see
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
just saw that the port ENV variable was missing
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
its being hosted via nginx
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
however on railway i'm getting a server error when i try to open the webapp
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
after i switched it to: tsc && doppler run -- vite build it started working
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
the issue was that the doppler variables were not being injected into the vite build process, it seems like it was being injected during the tsc command process
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
I just realised that my build command was the issue. I had this command for the npm run build script: doppler run -- tsc && vite build
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
Okay so the deployment was successful this time
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
ok one sec let me try that
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
Will this work on railway?
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
just a note this dockerfile builds perfectly fine and it works locally when i pass it a env_file to the docker-compose process etc
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
thats why i need to prune the webapp project and build it in this way as it has dependencies with another package in the monorepo
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
I am using turborepo
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
# ---------------------------------
# BUILD STAGE
# ---------------------------------
FROM node:18-alpine AS builder

RUN apk add --no-cache libc6-compat
RUN apk update

# Set working directory
WORKDIR /app

RUN yarn global add turbo

COPY . ./

RUN turbo prune --scope=webapp --docker
# ---------------------------------

# ---------------------------------
# INSTALL STAGE
# ---------------------------------
# Add lockfile and package.json's of isolated subworkspace
FROM node:18-alpine AS installer

RUN apk add --no-cache libc6-compat
RUN apk update

WORKDIR /app

# First install the dependencies (as they change less often)
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ ./
COPY --from=builder /app/out/yarn.lock ./yarn.lock
RUN yarn install

# 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...
# ---------------------------------

# ---------------------------------
# RUNNER STAGE (NGINX)
# ---------------------------------
FROM nginx:1.25-alpine

COPY --from=installer /app/apps/webapp/nginx/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=installer /app/apps/webapp/dist /usr/share/nginx/html

EXPOSE 80
# -------------------------------------
# ---------------------------------
# BUILD STAGE
# ---------------------------------
FROM node:18-alpine AS builder

RUN apk add --no-cache libc6-compat
RUN apk update

# Set working directory
WORKDIR /app

RUN yarn global add turbo

COPY . ./

RUN turbo prune --scope=webapp --docker
# ---------------------------------

# ---------------------------------
# INSTALL STAGE
# ---------------------------------
# Add lockfile and package.json's of isolated subworkspace
FROM node:18-alpine AS installer

RUN apk add --no-cache libc6-compat
RUN apk update

WORKDIR /app

# First install the dependencies (as they change less often)
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ ./
COPY --from=builder /app/out/yarn.lock ./yarn.lock
RUN yarn install

# 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...
# ---------------------------------

# ---------------------------------
# RUNNER STAGE (NGINX)
# ---------------------------------
FROM nginx:1.25-alpine

COPY --from=installer /app/apps/webapp/nginx/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=installer /app/apps/webapp/dist /usr/share/nginx/html

EXPOSE 80
# -------------------------------------
34 replies
RRailway
Created by mta.coder97 on 8/15/2023 in #✋|help
Help with deploying a react + vite app on railway using docker
Yes sure
34 replies