FROM ubuntu as developer-os
LABEL name="Edward Patch" email="1801492@student.uwtsd.ac.uk"
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update --fix-missing && \
    apt-get install -y \
    software-properties-common && \
    apt-get install -y --no-install-recommends apt-utils && \
    apt-get install -y curl \
    wget
RUN apt-get install -y sudo
RUN echo "export SERVER_IP_ADDRESS=0.0.0.0" >> /etc/profile
RUN apt-get clean

FROM developer-os as nodeenv
LABEL author="Edward Patch" email="1801492@student.uwtsd.ac.uk"
# Create and change the working directory
WORKDIR /var/www/node
RUN curl -fssL https://deb.nodesource.com/setup_17.x | sudo -E bash && \
apt-get install -y nodejs
RUN npm install -g npm && \
npm install -g npx --force
RUN apt-get install inotify-tools -y
RUN npm install -g nodemon
RUN apt-get clean


#### THE WEB SERVER ##############

FROM nodeenv as webserver
# Expose our webservers port number
EXPOSE 1500
# Change to the working directory
WORKDIR /var/www/node
# Execute the application
ENTRYPOINT ["npm", "run", "start-mount"]

#### THE WEB SERVICE ##############

FROM nodeenv as webservice
# Expose our webservices port number
EXPOSE 3000
# Change to the working directory
WORKDIR /var/www/node
# Execute the application
ENTRYPOINT ["npm", "run", "start-mount"]