Skip to content

Commit 0a0d7e3

Browse files
committed
Create dockerfile for dev and prod and adjust the files organization
1 parent 5e7e896 commit 0a0d7e3

File tree

7 files changed

+15
-100
lines changed

7 files changed

+15
-100
lines changed
File renamed without changes.
File renamed without changes.

Docker/prod.Dockerfile

Lines changed: 0 additions & 43 deletions
This file was deleted.

Dockerfile

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,27 @@ FROM node:14 AS development
22

33
ENV USERNAME timetracker
44
ENV HOME /home/${USERNAME}
5-
ENV CHROME_BIN /opt/google/chrome/google-chrome
6-
#Essential tools and xvfb
7-
RUN apt-get update && apt-get install -y \
8-
software-properties-common \
9-
unzip \
10-
curl \
11-
wget \
12-
xvfb
13-
14-
#Chrome browser to run the tests
15-
ARG CHROME_VERSION=65.0.3325.181
16-
RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add \
17-
&& wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
18-
&& dpkg -i google-chrome-stable_current_amd64.deb || true
19-
RUN apt-get install -y -f \
20-
&& rm -rf /var/lib/apt/lists/*
21-
22-
#Disable the SUID sandbox so that chrome can launch without being in a privileged container
23-
RUN dpkg-divert --add --rename --divert /opt/google/chrome/google-chrome.real /opt/google/chrome/google-chrome \
24-
&& echo "#! /bin/bash\nexec /opt/google/chrome/google-chrome.real --no-sandbox --disable-setuid-sandbox \"\$@\"" > /opt/google/chrome/google-chrome \
25-
&& chmod 755 /opt/google/chrome/google-chrome
26-
27-
#Chrome Driver
28-
ARG CHROME_DRIVER_VERSION=2.37
29-
RUN mkdir -p /opt/selenium \
30-
&& curl http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip -o /opt/selenium/chromedriver_linux64.zip \
31-
&& cd /opt/selenium; unzip /opt/selenium/chromedriver_linux64.zip; rm -rf chromedriver_linux64.zip; ln -fs /opt/selenium/chromedriver /usr/local/bin/chromedriver;
32-
335
RUN useradd -ms /bin/bash ${USERNAME}
34-
356
WORKDIR ${HOME}/time-tracker-ui
367
COPY . .
37-
RUN rm -f .env
388
RUN chown ${USERNAME}:${USERNAME} -R ${HOME}/time-tracker-ui
399
RUN chmod -R 777 ${HOME}/time-tracker-ui
4010

41-
4211
USER ${USERNAME}
4312
RUN npm cache clean --force && npm install
44-
EXPOSE 4200
45-
EXPOSE 9876
46-
CMD npm run config && ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck
47-
48-
4913

5014
FROM development as build
5115
COPY .env .
5216
RUN npm run config && npm run build
5317

54-
55-
5618
FROM nginx:1.21 AS production
5719

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

6123
COPY nginx.conf /etc/nginx/conf.d/default.conf
6224
COPY --from=build /home/timetracker/time-tracker-ui/dist/time-tracker /usr/share/nginx/html
63-
25+
COPY .env /usr/share/nginx/html
6426
RUN chown -R ${USERNAME}:${USERNAME} /var/cache/nginx && \
6527
chown -R ${USERNAME}:${USERNAME} /var/log/nginx && \
6628
chown -R ${USERNAME}:${USERNAME} /etc/nginx/conf.d
@@ -74,4 +36,4 @@ RUN touch /var/run/nginx.pid && chown -R ${USERNAME}:${USERNAME} /var/run/nginx.
7436

7537
# USER ${USERNAME}
7638

77-
EXPOSE 80
39+
EXPOSE 80

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ publish: require-acr-arg require-image_tag-arg ## Upload a docker image to the s
5656

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

6161
.PHONY: run_prod
6262
run_prod: ## Execute timetracker_ui_prod docker container.

docker-compose.dev.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

docker-compose.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services:
55
image: timetracker_ui
66
build:
77
context: .
8-
dockerfile: ./Docker/dev.Dockerfile
8+
dockerfile: ./Docker/Dockerfile.dev
99
ports:
1010
- 4200:4200
1111
- 9876:9876
@@ -19,12 +19,21 @@ services:
1919
AUTHORITY_JSON: ${AUTHORITY_JSON}
2020
CLIENT_ID_JSON: ${CLIENT_ID_JSON}
2121
SCOPES_JSON: ${SCOPES_JSON}
22+
volumes:
23+
- ./src:/home/timetracker/time-tracker-ui/src/
24+
- ./scripts:/home/timetracker/time-tracker-ui/scripts/
25+
- ./e2e:/home/timetracker/time-tracker-ui/e2e/
26+
- ./coverage:/home/timetracker/time-tracker-ui/coverage
27+
- ./angular.json:/home/timetracker/time-tracker-ui/angular.json
28+
- ./karma.conf.js:/home/timetracker/time-tracker-ui/karma.conf.js
29+
- ./package.json:/home/timetracker/time-tracker-ui/package.json
30+
- ./webpack.config.js:/home/timetracker/time-tracker-ui/webpack.config.js
2231
timetracker_ui_test:
2332
container_name: timetracker_ui_test
2433
image: timetracker_ui_test
2534
build:
2635
context: .
27-
dockerfile: ./Docker/test.Dockerfile
36+
dockerfile: ./Docker/Dockerfile.test
2837
ports:
2938
- 4200:4200
3039
- 9876:9876
@@ -38,4 +47,4 @@ services:
3847
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${AZURE_APP_CONFIGURATION_CONNECTION_STRING}
3948
AUTHORITY_JSON: ${AUTHORITY_JSON}
4049
CLIENT_ID_JSON: ${CLIENT_ID_JSON}
41-
SCOPES_JSON: ${SCOPES_JSON}
50+
SCOPES_JSON: ${SCOPES_JSON}

0 commit comments

Comments
 (0)