Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
FROM nginx:1.23.0

RUN apt-get update && apt-get upgrade -y

RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get install -y nodejs
FROM node:18 AS build

RUN \
apt-get install -y \
libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 \
libxss1 libasound2 libxtst6 xauth xvfb g++ make
ARG SHEET_ID
ARG SHEET_NAME

WORKDIR /src/build-your-own-radar
COPY package.json ./
Expand All @@ -17,7 +10,10 @@ RUN npm ci

COPY . ./

# Override parent node image's entrypoint script (/usr/local/bin/docker-entrypoint.sh),
# which tries to run CMD as a node command
ENTRYPOINT []
CMD ["./build_and_start_nginx.sh"]
RUN npm test && npm run build:prod

FROM nginx:1.23.0

COPY --from=build /src/build-your-own-radar/dist /opt/build-your-own-radar
COPY default.template /etc/nginx/conf.d/default.conf
CMD nginx -g 'daemon off;'
11 changes: 11 additions & 0 deletions src/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,14 @@ require('./analytics.js')
const Factory = require('./util/factory')

Factory().build()

if (process.env.SHEET_ID) {
Factory().build(process.env.SHEET_ID, process.env.SHEET_NAME)
} else {
const QueryParams = require('./util/queryParamProcessor')

var queryString = window.location.href.match(/sheetId(.*)/)
var queryParams = queryString ? QueryParams(queryString[0]) : {}

Factory().build(queryParams.sheetId, queryParams.sheetName)
}
8 changes: 1 addition & 7 deletions src/util/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ const CSVDocument = function (url) {
return self
}

const JSONFile = function (url) {
const JSONFile = function (url, title) {
var self = {}

self.build = function () {
Expand Down Expand Up @@ -284,12 +284,6 @@ const JSONFile = function (url) {
return self
}

const DomainName = function (url) {
var search = /.+:\/\/([^\\/]+)/
var match = search.exec(decodeURIComponent(url.replace(/\+/g, ' ')))
return match == null ? null : match[1]
}

const FileName = function (url) {
var search = /([^\\/]+)$/
var match = search.exec(decodeURIComponent(url.replace(/\+/g, ' ')))
Expand Down
6 changes: 5 additions & 1 deletion webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ if (env) {
}

const common = ['./src/common.js']
const main = ['./src/site.js']

const ASSET_PATH = process.env.ASSET_PATH || '/'

Expand All @@ -33,13 +34,16 @@ const plugins = [
'process.env.RINGS': JSON.stringify(process.env.RINGS),
'process.env.QUADRANTS': JSON.stringify(process.env.QUADRANTS),
'process.env.ADOBE_LAUNCH_SCRIPT_URL': JSON.stringify(process.env.ADOBE_LAUNCH_SCRIPT_URL),
'process.env.SHEET_ID': JSON.stringify(process.env.SHEET_ID),
'process.env.SHEET_NAME': JSON.stringify(process.env.SHEET_NAME)
}),
]

module.exports = {
context: __dirname,
entry: {
common: common,
common,
main,
},
output: {
path: buildPath,
Expand Down