Skip to content
Merged
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
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ RUN ln -s /srv/node/node_modules

RUN npm run build

RUN GITREF=$(git rev-parse HEAD) \
GITTAG=$(git name-rev --tags --name-only $GITREF) \
SOURCE='https://github.com/mozilla/addons-frontend' && \
echo "{\"source\": \"$SOURCE\", \
\"version\": \"$GITTAG\", \
\"commit\": \"$GITREF\"}" > version.json

ENV SERVER_HOST 0.0.0.0
ENV SERVER_PORT 4000

Expand Down
13 changes: 13 additions & 0 deletions src/core/server/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import log from 'core/logger';


const env = config.util.getEnv('NODE_ENV');
const version = path.join(config.get('basePath'), 'version.json');
const isDeployed = config.get('isDeployed');
const isDevelopment = config.get('isDevelopment');

Expand Down Expand Up @@ -65,6 +66,18 @@ function baseServer(routes, createStore, { appInstanceName = appName } = {}) {

app.use(Express.static(path.join(config.get('basePath'), 'dist')));

// Return version information as json
app.get('/__version__', (req, res) => {
fs.stat(version, (err) => {
if (err) {
res.sendStatus(415);
} else {
res.setHeader('Content-Type', 'application/json');
fs.createReadStream(version).pipe(res);
}
});
});

// Return 200 for csp reports - this will need to be overridden when deployed.
app.post('/__cspreport__', (req, res) => res.status(200).end('ok'));

Expand Down