Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Create dockerfile for dev and prod and adjust the files organization
  • Loading branch information
sbateca committed May 18, 2022
commit 0a0d7e33b21a5bec05ca91946e2e27eab5d8d49f
File renamed without changes.
File renamed without changes.
43 changes: 0 additions & 43 deletions Docker/prod.Dockerfile

This file was deleted.

42 changes: 2 additions & 40 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,27 @@ FROM node:14 AS development

ENV USERNAME timetracker
ENV HOME /home/${USERNAME}
ENV CHROME_BIN /opt/google/chrome/google-chrome
#Essential tools and xvfb
RUN apt-get update && apt-get install -y \
software-properties-common \
unzip \
curl \
wget \
xvfb

#Chrome browser to run the tests
ARG CHROME_VERSION=65.0.3325.181
RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add \
&& wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
&& dpkg -i google-chrome-stable_current_amd64.deb || true
RUN apt-get install -y -f \
&& rm -rf /var/lib/apt/lists/*

#Disable the SUID sandbox so that chrome can launch without being in a privileged container
RUN dpkg-divert --add --rename --divert /opt/google/chrome/google-chrome.real /opt/google/chrome/google-chrome \
&& echo "#! /bin/bash\nexec /opt/google/chrome/google-chrome.real --no-sandbox --disable-setuid-sandbox \"\$@\"" > /opt/google/chrome/google-chrome \
&& chmod 755 /opt/google/chrome/google-chrome

#Chrome Driver
ARG CHROME_DRIVER_VERSION=2.37
RUN mkdir -p /opt/selenium \
&& curl http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip -o /opt/selenium/chromedriver_linux64.zip \
&& cd /opt/selenium; unzip /opt/selenium/chromedriver_linux64.zip; rm -rf chromedriver_linux64.zip; ln -fs /opt/selenium/chromedriver /usr/local/bin/chromedriver;

RUN useradd -ms /bin/bash ${USERNAME}

WORKDIR ${HOME}/time-tracker-ui
COPY . .
RUN rm -f .env
RUN chown ${USERNAME}:${USERNAME} -R ${HOME}/time-tracker-ui
RUN chmod -R 777 ${HOME}/time-tracker-ui


USER ${USERNAME}
RUN npm cache clean --force && npm install
EXPOSE 4200
EXPOSE 9876
CMD npm run config && ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck



FROM development as build
COPY .env .
RUN npm run config && npm run build



FROM nginx:1.21 AS production

ENV USERNAME app
RUN useradd -ms /bin/bash ${USERNAME}

COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /home/timetracker/time-tracker-ui/dist/time-tracker /usr/share/nginx/html

COPY .env /usr/share/nginx/html
RUN chown -R ${USERNAME}:${USERNAME} /var/cache/nginx && \
chown -R ${USERNAME}:${USERNAME} /var/log/nginx && \
chown -R ${USERNAME}:${USERNAME} /etc/nginx/conf.d
Expand All @@ -74,4 +36,4 @@ RUN touch /var/run/nginx.pid && chown -R ${USERNAME}:${USERNAME} /var/run/nginx.

# USER ${USERNAME}

EXPOSE 80
EXPOSE 80
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ publish: require-acr-arg require-image_tag-arg ## Upload a docker image to the s

.PHONY: build_prod
build_prod: ## Create docker image with dependencies needed for production.
docker-compose build timetracker_ui_prod
docker build --target production -t timetracker_ui_prod -f Dockerfile .

.PHONY: run_prod
run_prod: ## Execute timetracker_ui_prod docker container.
Expand Down
13 changes: 0 additions & 13 deletions docker-compose.dev.yml

This file was deleted.

15 changes: 12 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
image: timetracker_ui
build:
context: .
dockerfile: ./Docker/dev.Dockerfile
dockerfile: ./Docker/Dockerfile.dev
ports:
- 4200:4200
- 9876:9876
Expand All @@ -19,12 +19,21 @@ services:
AUTHORITY_JSON: ${AUTHORITY_JSON}
CLIENT_ID_JSON: ${CLIENT_ID_JSON}
SCOPES_JSON: ${SCOPES_JSON}
volumes:
- ./src:/home/timetracker/time-tracker-ui/src/
- ./scripts:/home/timetracker/time-tracker-ui/scripts/
- ./e2e:/home/timetracker/time-tracker-ui/e2e/
- ./coverage:/home/timetracker/time-tracker-ui/coverage
- ./angular.json:/home/timetracker/time-tracker-ui/angular.json
- ./karma.conf.js:/home/timetracker/time-tracker-ui/karma.conf.js
- ./package.json:/home/timetracker/time-tracker-ui/package.json
- ./webpack.config.js:/home/timetracker/time-tracker-ui/webpack.config.js
timetracker_ui_test:
container_name: timetracker_ui_test
image: timetracker_ui_test
build:
context: .
dockerfile: ./Docker/test.Dockerfile
dockerfile: ./Docker/Dockerfile.test
ports:
- 4200:4200
- 9876:9876
Expand All @@ -38,4 +47,4 @@ services:
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${AZURE_APP_CONFIGURATION_CONNECTION_STRING}
AUTHORITY_JSON: ${AUTHORITY_JSON}
CLIENT_ID_JSON: ${CLIENT_ID_JSON}
SCOPES_JSON: ${SCOPES_JSON}
SCOPES_JSON: ${SCOPES_JSON}