-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better docker for the frontend (#240)
* Exclude vscode local settings * Switch the image to nginx with ENV support * Add some doc * Fix travis config * Ignore coverage data * Remove version labels * Fix the Dockerfile according to the recent refactoring * Cleanup * Change maintainer According to @woss request * Fix travis config
- Loading branch information
Showing
11 changed files
with
114 additions
and
20 deletions.
There are no files selected for viewing
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,4 @@ | ||
build | ||
Dockerfile | ||
node_modules | ||
.git |
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 |
---|---|---|
|
@@ -22,3 +22,6 @@ build | |
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.vscode | ||
env-config.js | ||
.nyc |
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
12 |
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,31 @@ | ||
#### BUILDER IMAGE #### | ||
FROM node:12 as builder | ||
LABEL maintainer="Chevdor <[email protected]>" | ||
LABEL description="Polkadot Telemetry frontend builder image" | ||
|
||
WORKDIR /opt/builder | ||
|
||
COPY . . | ||
RUN yarn install && \ | ||
yarn build && \ | ||
yarn cache clean | ||
|
||
|
||
#### OUTPUT IMAGE #### | ||
FROM nginx:stable-alpine | ||
LABEL maintainer="Chevdor <[email protected]>" | ||
LABEL description="Polkadot Telemetry frontend" | ||
|
||
ENV SUBSTRATE_TELEMETRY_URL= | ||
|
||
WORKDIR /usr/share/nginx/html | ||
|
||
COPY --from=builder /opt/builder/env.sh /usr/bin/ | ||
RUN apk add --no-cache bash; chmod +x /usr/bin/env.sh | ||
|
||
COPY --from=builder /opt/builder/nginx/nginx.conf /etc/nginx/nginx.conf | ||
COPY --from=builder /opt/builder/build /usr/share/nginx/html | ||
|
||
EXPOSE 80 | ||
|
||
CMD ["/bin/bash", "-c", "/usr/bin/env.sh && 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
# This script is used when the docker container starts and does the magic to | ||
# bring the ENV variables to the generated static UI. | ||
|
||
TARGET=./env-config.js | ||
|
||
# Recreate config file | ||
echo -n > $TARGET | ||
|
||
declare -a vars=( | ||
"SUBSTRATE_TELEMETRY_URL" | ||
"SUBSTRATE_TELEMETRY_SAMPLE" | ||
) | ||
|
||
echo "window.process_env = {" >> $TARGET | ||
for VAR in ${vars[@]}; do | ||
echo " $VAR: \"${!VAR}\"," >> $TARGET | ||
done | ||
echo "}" >> $TARGET |
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,27 @@ | ||
user nginx; | ||
worker_processes 1; | ||
|
||
error_log /var/log/nginx/error.log warn; | ||
pid /var/run/nginx.pid; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
access_log /var/log/nginx/access.log main; | ||
|
||
sendfile on; | ||
#tcp_nopush on; | ||
|
||
keepalive_timeout 65; | ||
gzip on; | ||
include /etc/nginx/conf.d/*.conf; | ||
} |
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,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
cd `git rev-parse --show-toplevel` | ||
|
||
IMAGE=telemetry-frontend | ||
DOCKER_USER=${DOCKER_USER:-paritytech} | ||
echo "Publishing $IMAGE as $DOCKER_USER" | ||
|
||
docker build -t $IMAGE -f packages/frontend/Dockerfile . | ||
docker tag $IMAGE $DOCKER_USER/$IMAGE | ||
docker push $DOCKER_USER/$IMAGE |