FROM {{ DOCKER_URL }}/nodets:latest AS builder

WORKDIR /app

ENV NODE_ENV=production

{{ ENV_TEMPLATE }}

# Install
COPY package*.json ./
RUN npm install

# Copy
COPY . .

# Build
RUN tsc
RUN npm run build

RUN find build/static -type f -name "*.js" -exec gzip -9 -k {} \; \
    && find build/static -type f -name "*.css" -exec gzip -9 -k {} \;

FROM {{ DOCKER_URL }}/nginx:latest

COPY --from=builder /app/build /app

EXPOSE 3000

CMD ["nginx", "-g", "daemon off;"]