Skip to content

Commit 0be42b3

Browse files
committed
marge master
2 parents 0a462ea + 69a2ef9 commit 0be42b3

File tree

27 files changed

+314
-138
lines changed

27 files changed

+314
-138
lines changed

.github/workflows/CD-time-tracker-ui.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ jobs:
3535
STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.stack_exchange_access_token }}
3636
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.azure_app_configuration_connection_string }}
3737
run: |
38-
chmod +x ./scripts/populate-var-file.sh
39-
sh ./scripts/populate-var-file.sh
38+
chmod +x ./scripts/populate-keys.sh
39+
sh ./scripts/populate-keys.sh
4040
4141
- name: 'run: npm install and build'
4242
run: |
43+
set -a
44+
source .env
45+
set +a
4346
npm install
4447
npm run build --prod --if-present
4548
cp scripts/default-static-site.js ${BUILD_PATH}

.github/workflows/CI-time-tracker-ui.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,16 @@ jobs:
4848
STACK_EXCHANGE_ACCESS_TOKEN: ${{ secrets.STACK_EXCHANGE_ACCESS_TOKEN }}
4949
AZURE_APP_CONFIGURATION_CONNECTION_STRING: ${{ secrets.AZURE_APP_CONFIGURATION_CONNECTION_STRING }}
5050
run: |
51-
chmod +x ./scripts/populate-var-file.sh
52-
sh ./scripts/populate-var-file.sh
51+
chmod +x ./scripts/populate-keys.sh
52+
sh ./scripts/populate-keys.sh
5353
5454
- name: Running tests
55-
run: npm run ci-test --if-present
55+
run: |
56+
set -a
57+
source .env
58+
set +a
59+
npm run ci-test --if-present
60+
rm .env
5661
5762
- name: Generate coverage report
5863
env:

.github/workflows/time-tracker-ui-cd-prod.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ jobs:
3939
4040
- name: Setup terraform
4141
uses: hashicorp/setup-terraform@v1
42+
with:
43+
terraform_version: 1.1.9
4244

4345
- name: Authenticate with the TF modules repository
4446
uses: webfactory/[email protected]

.github/workflows/time-tracker-ui-cd-stage.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ jobs:
3838
3939
- name: Setup terraform
4040
uses: hashicorp/setup-terraform@v1
41+
with:
42+
terraform_version: 1.1.9
4143

4244
- name: Authenticate with the TF modules repository
4345
uses: webfactory/[email protected]

.github/workflows/time-tracker-ui-ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ jobs:
5656

5757
- name: Setup terraform
5858
uses: hashicorp/setup-terraform@v1
59+
with:
60+
terraform_version: 1.1.9
5961

6062
- name: 'Terraform Init'
6163
id: init

Docker/Dockerfile.dev

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM node:14
2+
3+
ENV USERNAME timetracker
4+
ENV HOME /home/${USERNAME}
5+
RUN useradd -ms /bin/bash ${USERNAME}
6+
7+
WORKDIR ${HOME}/time-tracker-ui
8+
COPY . .
9+
RUN chown ${USERNAME}:${USERNAME} -R ${HOME}/time-tracker-ui \
10+
&& chmod -R 777 ${HOME}/time-tracker-ui
11+
12+
USER ${USERNAME}
13+
RUN npm cache clean --force && npm install
14+
EXPOSE 4200
15+
CMD ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck

Docker/Dockerfile.test

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM node:14
2+
3+
ARG CHROME_VERSION=65.0.3325.181
4+
ARG CHROME_DRIVER_VERSION=2.37
5+
ENV USERNAME timetracker
6+
ENV HOME /home/${USERNAME}
7+
ENV CHROME_BIN /opt/google/chrome/google-chrome
8+
9+
#Essential tools and xvfb
10+
RUN apt-get update && apt-get install -y \
11+
software-properties-common \
12+
unzip \
13+
curl \
14+
wget \
15+
xvfb
16+
17+
#Chrome browser to run the tests
18+
RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add \
19+
&& wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
20+
&& dpkg -i google-chrome-stable_current_amd64.deb || true
21+
RUN apt-get install -y -f \
22+
&& rm -rf /var/lib/apt/lists/*
23+
24+
#Disable the SUID sandbox so that chrome can launch without being in a privileged container
25+
RUN dpkg-divert --add --rename --divert /opt/google/chrome/google-chrome.real /opt/google/chrome/google-chrome \
26+
&& echo "#! /bin/bash\nexec /opt/google/chrome/google-chrome.real --no-sandbox --disable-setuid-sandbox \"\$@\"" > /opt/google/chrome/google-chrome \
27+
&& chmod 755 /opt/google/chrome/google-chrome
28+
29+
#Chrome Driver
30+
RUN mkdir -p /opt/selenium \
31+
&& curl http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip -o /opt/selenium/chromedriver_linux64.zip \
32+
&& cd /opt/selenium; unzip /opt/selenium/chromedriver_linux64.zip; rm -rf chromedriver_linux64.zip; ln -fs /opt/selenium/chromedriver /usr/local/bin/chromedriver;
33+
34+
RUN useradd -ms /bin/bash ${USERNAME}
35+
36+
WORKDIR ${HOME}/time-tracker-ui
37+
COPY . .
38+
RUN rm -f .env
39+
RUN chown ${USERNAME}:${USERNAME} -R ${HOME}/time-tracker-ui
40+
RUN chmod -R 777 ${HOME}/time-tracker-ui
41+
42+
USER ${USERNAME}
43+
COPY .env .
44+
EXPOSE 4200
45+
EXPOSE 9876
46+
RUN npm cache clean --force && npm install
47+
CMD npm run ci-test

Dockerfile

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,23 @@ 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
4413
EXPOSE 4200
4514
EXPOSE 9876
46-
CMD npm run config && ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck
15+
CMD ${HOME}/time-tracker-ui/node_modules/.bin/ng serve --host 0.0.0.0 --disableHostCheck
4716

4817

4918

5019
FROM development as build
5120
COPY .env .
52-
RUN npm run config && npm run build
53-
54-
21+
RUN npm run build
5522

5623
FROM nginx:1.21 AS production
5724

@@ -60,7 +27,7 @@ RUN useradd -ms /bin/bash ${USERNAME}
6027

6128
COPY nginx.conf /etc/nginx/conf.d/default.conf
6229
COPY --from=build /home/timetracker/time-tracker-ui/dist/time-tracker /usr/share/nginx/html
63-
30+
COPY .env /usr/share/nginx/html
6431
RUN chown -R ${USERNAME}:${USERNAME} /var/cache/nginx && \
6532
chown -R ${USERNAME}:${USERNAME} /var/log/nginx && \
6633
chown -R ${USERNAME}:${USERNAME} /etc/nginx/conf.d
@@ -74,4 +41,4 @@ RUN touch /var/run/nginx.pid && chown -R ${USERNAME}:${USERNAME} /var/run/nginx.
7441

7542
# USER ${USERNAME}
7643

77-
EXPOSE 80
44+
EXPOSE 80

Makefile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ help: ## Show this help message.
1111

1212
.PHONY: build
1313
build: ## Create docker image with dependencies needed for development.
14-
docker-compose build
14+
docker-compose build timetracker_ui
1515

1616
.PHONY: cleanup
1717
cleanup: ## Delete image timetracker_ui
1818
docker rmi timetracker_ui
1919

2020
.PHONY: run
21-
run: ## Execute timetracker_ui docker containe.
22-
docker-compose up -d
21+
run: ## Execute timetracker_ui dev docker containe.
22+
docker-compose up -d timetracker_ui
2323

2424
.PHONY: logs
2525
logs: ## Show logs of timetracker_ui.
@@ -40,8 +40,9 @@ remove: ## Delete container timetracker_ui.
4040

4141
.PHONY: test
4242
test: ## Run all tests on docker container timetracker_ui at the CLI.
43-
docker-compose -f docker-compose.yml up -d
44-
docker exec timetracker_ui bash -c "npm run ci-test"
43+
docker-compose build timetracker_ui_test
44+
docker-compose up -d timetracker_ui_test
45+
docker logs -f timetracker_ui_test
4546

4647
.PHONY: testdev
4748
testdev: ## Run all tests on docker container timetracker_ui at the Dev
@@ -59,7 +60,7 @@ build_prod: ## Create docker image with dependencies needed for production.
5960

6061
.PHONY: run_prod
6162
run_prod: ## Execute timetracker_ui_prod docker container.
62-
docker run -d -p 4200:4200 --name timetracker_ui_prod timetracker_ui_prod
63+
docker run -d -p 80:80 --env-file ./.env --name timetracker_ui_prod timetracker_ui_prod
6364

6465
.PHONY: stop_prod
6566
stop_prod: ## Stop container timetracker_ui_prod.

docker-compose.dev.yml

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

0 commit comments

Comments
 (0)