FROM node:lts AS build

ARG origin=https://barretthousen.com

ENV PROTOCOL_HEADER=x-forwarded-proto
ENV HOST_HEADER=x-forwarded-host
ENV ORIGIN=${origin}

WORKDIR /opt/web-client

COPY . /opt/web-client

RUN npm ci && npm run build \
	&& cp -v /opt/web-client/package.json /opt/web-client/build \
	&& cp -v /opt/web-client/package-lock.json /opt/web-client/build \
	&& cd /opt/web-client/build && npm ci --omit dev

FROM node:lts AS production

LABEL com.barretthousen.service="web-client"
LABEL com.barretthousen.tags="frontend,public"
LABEL com.barretthousen.release-date="2023-05-01"
LABEL com.barretthousen.version="alpha-0.0.1"
LABEL com.barretthousen.git-ref="000000000000000000000000000000000000000000000000"

ARG origin=https://barretthousen.com

ENV ENV=production
ENV PROTOCOL_HEADER=x-forwarded-proto
ENV HOST_HEADER=x-forwarded-host
ENV ORIGIN=${origin}

WORKDIR /opt

COPY --from=build /opt/web-client/build/ /opt/web-client/

ENV PORT 80

EXPOSE 80

ENTRYPOINT ["node", "web-client"]

