-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
159 lines (109 loc) · 4.29 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Specify the base Docker image. You can read more about
# the available images at https://crawlee.dev/docs/guides/docker-images
# You can also use any other image from Docker Hub.
FROM apify/actor-node-playwright-chrome:18 AS builder
# Install pnpm
# RUN wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.bashrc" SHELL="$(which bash)" bash -
USER root
WORKDIR /home/myuser
# Set NPM_CONFIG_PREFIX
# ENV PNPM_HOME="/home/myuser/.local/share/pnpm/"
# ENV PATH="${PATH}:${PNPM_HOME}"
ENV NODE_ENV=development
RUN npm install -g pnpm
# Use the shell form of RUN to source the .bashrc file before running pnpm
# SHELL ["/bin/bash", "-c", "source /home/myuser/.bashrc"]
COPY ./interface/package.json ./interface/
COPY ./interface/pnpm-lock.yaml ./interface/
# Change ownership of the interface directory to myuser
RUN chown -R myuser:myuser /home/myuser/interface
USER myuser
# RUN pnpm add -g typescript @types/node
RUN cd ./interface && pnpm install
USER root
# Copy just package.json and pnpm-lock.yaml
# to speed up the build using Docker layer cache.
COPY ./scraper/package.json ./scraper/
COPY ./scraper/pnpm-lock.yaml ./scraper/
RUN chown -R myuser:myuser /home/myuser/scraper
USER myuser
# Install all dependencies.
RUN cd ./scraper && pnpm install
USER root
# Next, copy the source files using the user set
# in the base image.
COPY ./interface ./interface
# Change ownership of the interface directory to myuser
RUN chown -R myuser:myuser /home/myuser/interface
USER myuser
# Install all dependencies and build the project.
# Don't audit to speed up the installation.
RUN cd ./interface && pnpm run build
USER root
COPY ./scraper ./scraper
RUN chown -R myuser:myuser /home/myuser/scraper
USER myuser
RUN cd ./scraper && pnpm run build
# Create final image
FROM apify/actor-node-playwright-chrome:18
# Install pnpm
# RUN wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.bashrc" SHELL="$(which bash)" bash -
USER root
WORKDIR /home/myuser
RUN npm install -g pnpm
USER myuser
# Use the shell form of RUN to source the .bashrc file before running pnpm
# SHELL ["/bin/bash", "-c", "source /home/myuser/.bashrc"]
# Copy only built JS files and from builder image
COPY --from=builder /home/myuser/interface/dist ./app/interface/dist
COPY --from=builder /home/myuser/scraper/dist ./app/scraper/dist
# Copy just package.json and pnpm-lock.yaml
# to speed up the build using Docker layer cache.
COPY ./interface/package.json ./app/interface/
COPY ./interface/pnpm-lock.yaml ./app/interface/
COPY ./scraper/package.json ./app/scraper/
COPY ./scraper/pnpm-lock.yaml ./app/scraper/
USER root
# Change ownership of the interface directory to myuser
RUN chown -R myuser:myuser /home/myuser/app
USER myuser
# Install NPM packages, skip optional and development dependencies to
# keep the image small. Avoid logging too much and print the dependency
# tree for debugging
RUN cd ./app/scraper \
&& pnpm install --prod -s \
&& echo "Installed PNPM packages:" \
&& (pnpm list --prod || true) \
&& echo "Node.js version:" \
&& node --version \
&& echo "PNPM version:" \
&& pnpm --version
RUN cd ./app/interface \
&& pnpm install --prod -s \
&& echo "Installed PNPM packages:" \
&& (pnpm list --prod || true)
USER root
# Install python
RUN apt-get update && apt-get install -y python3 python3-pip
USER myuser
COPY stringNormalizers/verToSemVer/hardCodedApproach ./app/stringNormalizers/verToSemVer/hardCodedApproach
# Install python dependencies
RUN pip3 install -r ./app/stringNormalizers/verToSemVer/hardCodedApproach/requirements.txt
COPY stringNormalizers/nameToStdName ./app/stringNormalizers/nameToStdName
RUN pip3 install -r ./app/stringNormalizers/nameToStdName/requirements.txt
# Next, copy the remaining files and directories with the source code.
# Since we do this after NPM install, quick build will be really fast
# for most source file changes.
COPY . ./app/
USER root
# Change ownership of the interface directory to myuser
RUN chown -R myuser:myuser /home/myuser/app
USER myuser
# Change working directory to /usr/src/app/scraper
WORKDIR /home/myuser/app/scraper
VOLUME "/home/myuser/repository"
CMD ../../start_xvfb_and_run_cmd.sh && node dist/main.js --mode new --source bukkit
# ENTRYPOINT ["/bin/sh", "-c", "/usr/bin/xvfb-run -a $@", ""]
# ENTRYPOINT ["node"]
# CMD ["dist/main.js"]
# ENTRYPOINT ["bash"]