My dockerized React app is unreachable on fly.dev. It has HTTPS enabled, and is running on port 5000. My Dockerfile looks like this:
FROM node:18-alpine
WORKDIR /app
COPY public/ /app/public
COPY src/ /app/src
COPY package.json /app
COPY package-lock.json /app
COPY .env /app
RUN npm install
EXPOSE 5000
CMD [“npm”, “start”]
I have the [env] set to
PORT = 5000
HTTPS = true
HOST = “0.0.0.0”
After a lot of research, I found a working solution, and I’ll post it here for when somebody else needs it. The trick was to use nginx, but that doesn’t work with React unless you add a nginx.conf file.
Dockerfile:
FROM node:18-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
I tried turning of HTTS and it didn’t work for me. Maybe I’ll try it again at some point in time because the simpler the solution the better, but for now, this is a working solution as well.