strava-frontend/Dockerfile

37 lines
929 B
Docker

### STAGE 1: Build ----------------------------------------------------------------------------------------------------
FROM node:20-alpine AS build
ARG VERSION
ARG BUILD
ARG TARGETENV
LABEL version=$VERSION build=$BUILD mode=$TARGETENV
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
COPY . .
RUN yarn build
### STAGE 2: Runtime -------------------------------------------------------------------------------------------------
FROM node:20-alpine
RUN apk add --no-cache nginx
WORKDIR /app
COPY --from=build /app/dist /usr/share/nginx/html
COPY --from=build /app/node_modules /app/node_modules
COPY --from=build /app/server /app/server
COPY --from=build /app/package.json /app/package.json
COPY nginx.conf /etc/nginx/nginx.conf
RUN rm -f /etc/nginx/conf.d/default.conf
EXPOSE 80
ENV DIST_PATH=/usr/share/nginx/html
CMD ["sh", "-c", "npx tsx server/index.ts & nginx -g 'daemon off;'"]