# syntax=docker/dockerfile:1.4
FROM  594765360358.dkr.ecr.ca-central-1.amazonaws.com/tbi-php-80:latest
ARG TARGET_SITE=redtag

# Update package repositories
RUN sed -i 's/buster/oldoldstable/g' /etc/apt/sources.list && \
    apt-get update

RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
    apt-get install -y nodejs git zip

COPY . /var/www/html/
RUN mv /var/www/html/.env /var/www/.env

RUN curl -L https://github.com/composer/composer/releases/download/2.3.7/composer.phar > /usr/local/bin/composer && \
    chmod +x /usr/local/bin/composer

WORKDIR /var/www/html

USER root

# Provide the Git SSH key for private composer repos via a BuildKit SSH mount
# instead of baking a committed key into the image. Build with:
#   DOCKER_BUILDKIT=1 docker build -f Dockerfile.dev --ssh default=$HOME/.ssh/id_jenkins .
RUN mkdir -p -m 0700 /root/.ssh && \
    ssh-keyscan github.com >> /root/.ssh/known_hosts

RUN --mount=type=ssh composer install -n
RUN --mount=type=ssh cd /var/www/html/vacations && composer install -n
RUN cd /var/www/html/ && npm install
RUN npm run prod

RUN chown -R www-data:www-data /var/www/html
