Commit 036d5aeb authored by Vincent's avatar Vincent

Also build the website and serve it in production

parent aeb17596
Pipeline #22240484 passed with stage
in 3 minutes and 57 seconds
......@@ -38,6 +38,6 @@ Deployment is done by GitLab CI/CD when new commits are pushed to the `master` b
## `plaudit-website`
This is relatively independent of the other packages, although it is served up by `plaudit-server` as well in production.
This is relatively independent of the other packages, although it is served up by `plaudit-server` as well in production. To run it locally, run `yarn start` from the `website` directory, after running `yarn` to install dependencies if needed.
The website runs on [Gatsby](https://www.gatsbyjs.org/), using [Bulma](https://bulma.io/) for styling.
......@@ -26,6 +26,7 @@
"@types/storybook__react": "^3.0.7",
"typescript": "^2.8.3"
},
"homepage": "https://plauditpub.herokuapp.com/widget",
"proxy": {
"/api": {
"target": "http://localhost:5000"
......
version: '2'
services:
web:
app:
image: plaudit
build:
context: .
dockerfile: docker/web/Dockerfile
dockerfile: docker/app/Dockerfile
ports:
- 5000:5000
- 3000:3000
......@@ -14,6 +14,9 @@ services:
# Prevent locally installed node_modules from being mounted inside the container.
- /usr/src/app/node_modules
- /usr/src/app/client/node_modules
- /usr/src/app/server/node_modules
# We also do not run the website in this container
- /usr/src/app/website
links:
- database
environment:
......
......@@ -8,5 +8,6 @@ RUN apk add --no-cache python make g++
COPY ["./package.json", "yarn.lock", "/usr/src/app/"]
COPY ["./server/package.json", "server/yarn.lock", "/usr/src/app/server/"]
COPY ["./client/package.json", "client/yarn.lock", "/usr/src/app/client/"]
EXPOSE 3000
EXPOSE 5000
CMD yarn; yarn watch
\ No newline at end of file
......@@ -2,10 +2,10 @@
"name": "plaudit",
"version": "1.0.0",
"scripts": {
"build": "rm -rf dist/; cd server; yarn run build; cd ../; mkdir -p dist/server; cp -r server/dist/server/* dist/server; cp -r server/node_modules dist/server/; cd client; yarn run build; cd ../; mkdir -p dist/client; cp -r client/build/* dist/client; cp -r client/node_modules dist/client/",
"build": "rm -rf dist/; cd server; yarn run build; cd ../; mkdir -p dist/server; cp -r server/dist/server/* dist/server; cp -r server/node_modules dist/server/; cd client; yarn run build; cd ../; mkdir -p dist/client; cp -r client/build/* dist/client; cp -r client/node_modules dist/client/; cd website; rm -rf public/; yarn run build; cd ../; mkdir -p dist/website; cp -r website/public/* dist/website;",
"watch": "concurrently \"cd server; yarn watch;\" \"cd client; yarn watch;\"",
"start": "cd dist/server; node index.js",
"postinstall": "cd server; yarn; cd ../client; yarn",
"postinstall": "cd server; yarn; cd ../client; yarn; cd ../website; yarn",
"heroku-postbuild": "yarn run build"
},
"description": "Open community endorsements",
......
......@@ -12,10 +12,11 @@ const initialise = async () => {
addEndorsements(app);
if (process.env.NODE_ENV === 'production') {
app.use(express.static(path.join(__dirname, '../client'), { extensions: [ 'html' ] }));
app.use(express.static(path.join(__dirname, '../website'), { extensions: [ 'html' ] }));
app.use('/widget', express.static(path.join(__dirname, '../client'), { extensions: [ 'html' ] }));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, '../client/index.html'));
res.sendFile(path.join(__dirname, '../website/index.html'));
});
}
......
GATSBY_APP_URL=http://localhost:3000
\ No newline at end of file
import * as React from 'react'
const DemoPage = () => (
<section className="section">
<div className="container">
<h1 className="title">Demo</h1>
<iframe src={process.env.GATSBY_APP_URL + '/widget/?doi=10.7554/elife.36263'} frameBorder={0}/>
</div>
</section>
)
export default DemoPage
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment