-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from privacybydesign/dockerize
Fixing bugs and improvements on the docker image
- Loading branch information
Showing
7 changed files
with
114 additions
and
95 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,45 @@ | ||
FROM python:3.9-slim | ||
# --- Stage 1 Node build | ||
FROM node:18-slim AS node-build | ||
|
||
WORKDIR / | ||
WORKDIR /app | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y curl apache2 && \ | ||
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ | ||
apt-get install -y nodejs && \ | ||
npm install -g yarn && \ | ||
pip install Jinja2 && \ | ||
pip install requests | ||
COPY src ./ | ||
COPY webpack.config.js yarn.lock package.json ./ | ||
|
||
ENV NODE_OPTIONS=--openssl-legacy-provider | ||
RUN yarn install --frozen-lockfile | ||
|
||
ENV NODE_OPTIONS="--openssl-legacy-provider" | ||
COPY . . | ||
RUN python3 download_repos.py && \ | ||
python3 -u update.py && \ | ||
test -f index.json && \ | ||
yarn && yarn build && \ | ||
mkdir -p /var/www/html && \ | ||
cp -r /en /var/www/html/ && \ | ||
cp -r /nl /var/www/html/ && \ | ||
cp -r /repos /var/www/html/ && \ | ||
cp style.css /var/www/html/ && \ | ||
cp logo.svg /var/www/html/ && \ | ||
cp script.js /var/www/html/ && \ | ||
cp index.json /var/www/html/ | ||
RUN yarn build | ||
|
||
# --- Stage 2 Python build | ||
FROM python:3.9-slim AS python-build | ||
|
||
WORKDIR /app | ||
COPY --from=node-build /app ./ | ||
|
||
COPY download_repos.py generate-index.py config.json ./ | ||
RUN ls -l /app | ||
|
||
RUN pip install --no-cache-dir Jinja2 requests && \ | ||
python3 download_repos.py && \ | ||
python3 -u generate-index.py | ||
|
||
# --- Stage 3: Final nginx stage | ||
FROM nginx:stable | ||
|
||
COPY nginx.conf /etc/nginx/conf.d/default.conf | ||
|
||
COPY --from=python-build /app/en/ /var/www/html/en/ | ||
COPY --from=python-build /app/nl/ /var/www/html/nl/ | ||
COPY --from=python-build /app/repos/ /var/www/html/repos/ | ||
COPY --from=python-build /app/index.json /var/www/html/ | ||
COPY --from=node-build /app/script.js /var/www/html/ | ||
COPY style.css logo.svg /var/www/html/ | ||
|
||
RUN chown -R nginx:nginx /var/www/html && \ | ||
chmod -R 755 /var/www/html | ||
|
||
EXPOSE 80 | ||
|
||
CMD ["apache2ctl", "-D", "FOREGROUND"] | ||
CMD ["nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: '3.8' | ||
|
||
services: | ||
attribute-index: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
ports: | ||
- "80:80" | ||
environment: | ||
- NODE_OPTIONS=--openssl-legacy-provider | ||
restart: unless-stopped |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
server { | ||
listen 80; | ||
server_name _; | ||
root /var/www/html; | ||
index index.html; | ||
charset utf-8; | ||
|
||
location / { | ||
if ($uri = /) { | ||
return 301 /en; | ||
} | ||
try_files $uri $uri/ =404; | ||
add_header Content-Type "text/html; charset=utf-8"; | ||
} | ||
location ~* \.(css|js|svg|png|jpg|jpeg|gif|ico|woff|woff2|ttf|eot)$ { | ||
root /var/www/html; | ||
try_files $uri =404; | ||
access_log off; | ||
expires max; | ||
add_header Cache-Control "public"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters