-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathDockerfile
126 lines (94 loc) · 4.78 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
FROM node:20
RUN apt-get update && \
apt-get install -qq -y wget
# Install the latest version of npm
RUN npm install -g --ignore-scripts npm@latest
# Set DATABASE_URI to be localhost
ENV DATABASE_URI=mongodb://localhost:27017
# Create app directory
WORKDIR /usr/src/app
# install mongoDB
RUN apt-get -y install gnupg curl
RUN curl -fsSL https://pgp.mongodb.com/server-7.0.asc | \
gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
--dearmor
RUN echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] http://repo.mongodb.org/apt/debian bookworm/mongodb-org/7.0 main" | tee /etc/apt/sources.list.d/mongodb-org-7.0.list
RUN apt-get update && apt-get -y install mongodb-org
RUN mkdir /data
RUN mkdir /data/db
RUN mongod --fork --logpath /var/log/mongodb.log
# ----- BACKEND (from /backend dockerfile) ------------------------------------------------------------------------
# install chrome
RUN wget -q --max-redirect=0 https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN yes | apt install -qq ./google-chrome-stable_current_amd64.deb
RUN rm -f google-chrome-stable_current_amd64.deb
# install chromedriver
RUN apt-get -q install -yqq unzip curl
RUN wget -q -O /tmp/chromedriverzip.zip https://storage.googleapis.com/chrome-for-testing-public/$(curl https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_STABLE)/linux64/chromedriver-linux64.zip
RUN unzip /tmp/chromedriverzip.zip chromedriver-linux64/chromedriver -d /usr/local/bin/
RUN mv /usr/local/bin/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver
# install firefox
RUN wget -q -O ~/FirefoxSetup.tar.bz2 "https://download.mozilla.org/?product=firefox-latest&os=linux64"
RUN tar xjf ~/FirefoxSetup.tar.bz2 -C /opt/
RUN ln -s /opt/firefox/firefox /usr/local/bin/
RUN apt-get -q update && apt-get install -qq -y bzip2 libdbus-glib-1-2 libgtk-3-0 libpci-dev libx11-xcb-dev libxt6 libxtst6 wget && rm -rf /var/lib/apt/lists/*
# # install edge
# RUN curl -q https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
# RUN install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
# RUN sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-dev.list'
# RUN rm microsoft.gpg
# RUN apt-get -q update && apt-get install -qq -y microsoft-edge-stable
# # include in path
# RUN export PATH=$PATH:/opt/microsoft/msedge/
# ENV PATH="${PATH}:/opt/microsoft/msedge/"
# # install msedgedriver
# # # Extract the latest stable version of edge
# RUN msedge --version | sed 's/.*Edge \([0-9.]*\).*/\1/' > latest_stable.txt
# # # Remove the driver-pagehtml
# RUN wget -q -O /tmp/msedgedriver.zip https://msedgedriver.azureedge.net/$(cat latest_stable.txt)/edgedriver_linux64.zip
# RUN unzip /tmp/msedgedriver.zip msedgedriver -d /usr/local/bin/
# RUN rm -f latest_stable.txt
# Install edge via package manager
RUN apt-get update && apt-get install -qq -y software-properties-common
RUN curl -q https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.gpg
RUN add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main"
RUN apt-get update && apt-get install -qq -y microsoft-edge-stable
# Install msedgedriver
RUN npm install --ignore-scripts -g edgedriver node-fetch
# Show Edge and EdgeDriver version
RUN microsoft-edge --version
RUN edgedriver --version
# Clean up the cache after installing all necessary packages
RUN apt-get -q update && apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app/backend
# Bundle app source
COPY ./backend .
RUN npm ci
# If you are building your code for production
# RUN npm ci --only=production
EXPOSE 8080
# Start dbus-daemon for google-chrome
RUN service dbus start
# ----- FRONTEND (from /frontend dockerfile) ---------------------------------------------------------------------
# Create app directory
WORKDIR /usr/src/app/frontend
# Copy package.json and package-lock.json
COPY ./frontend/package*.json ./
# Install dependencies
RUN npm ci --ignore-scripts
# Install Angular CLI
RUN npm install --ignore-scripts -g @angular/cli
COPY ./frontend .
EXPOSE 4200
EXPOSE 27017-27019
RUN npm run build
# -----------------------------------------------------------------------------------------------------------------
# Create a startup script
RUN echo "#!/bin/sh" > /usr/src/app/start.sh && \
echo "mongod --fork --logpath /var/log/mongodb.log" >> /usr/src/app/start.sh && \
echo "cd /usr/src/app/backend && npm run database && npm run database-examples && npm run start &" >> /usr/src/app/start.sh && \
echo "cd /usr/src/app/frontend && node server.js" >> /usr/src/app/start.sh
# Make the script executable
RUN chmod +x /usr/src/app/start.sh
# Set the script as the ENTRYPOINT
ENTRYPOINT ["/usr/src/app/start.sh"]