Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
ffa7e1a4de | |||
30ced3ecfd | |||
4bc8c00c49 | |||
e33ba9707c | |||
9af4af6c5d | |||
d88689ee31 | |||
1d544dad0b |
27
Makefile
27
Makefile
@ -1,15 +1,32 @@
|
|||||||
VERSION=`git describe --always`
|
VERSION:=$(shell git describe --always)
|
||||||
|
TARGET_ENV=prod
|
||||||
|
|
||||||
build: build-api build-web
|
build: dist/personal-measure-api.tar.gz dist/personal-measure-web.tar.gz
|
||||||
|
|
||||||
build-api:
|
dist/personal-measure-api.tar.gz:
|
||||||
-mkdir dist
|
-mkdir dist
|
||||||
make -C api personal_measure_api
|
make -C api personal_measure_api
|
||||||
tar czf dist/personal-measure-api-${VERSION}.tar.gz -C api personal_measure_api
|
tar czf dist/personal-measure-api-${VERSION}.tar.gz -C api personal_measure_api
|
||||||
|
cp dist/personal-measure-api-${VERSION}.tar.gz dist/personal-measure-api.tar.gz
|
||||||
|
|
||||||
build-web:
|
dist/personal-measure-web.tar.gz:
|
||||||
-mkdir dist
|
-mkdir dist
|
||||||
(cd web && npm run build)
|
(cd web && npm run build)
|
||||||
tar czf dist/personal-measure-web-${VERSION}.tar.gz -C web/dist .
|
tar czf dist/personal-measure-web-${VERSION}.tar.gz -C web/dist .
|
||||||
|
cp dist/personal-measure-web-${VERSION}.tar.gz dist/personal-measure-web.tar.gz
|
||||||
|
|
||||||
#deploy-api: build-api
|
deploy-api: dist/personal-measure-api.tar.gz
|
||||||
|
mkdir -p temp-deploy/personal-measure-api-${VERSION}
|
||||||
|
tar xzf dist/personal-measure-api-${VERSION}.tar.gz -C temp-deploy/personal-measure-api-${VERSION}
|
||||||
|
-ssh pmapi@pmapi.jdb-labs.com "sudo systemctl stop personal_measure_api.$(TARGET_ENV).service"
|
||||||
|
scp temp-deploy/personal-measure-api-${VERSION}/personal_measure_api pmapi@pmapi.jdb-labs.com:/home/pmapi/$(TARGET_ENV)/personal_measure_api
|
||||||
|
ssh pmapi@pmapi.jdb-labs.com "sudo systemctl start personal_measure_api.$(TARGET_ENV).service"
|
||||||
|
rm -r temp-deploy
|
||||||
|
|
||||||
|
deploy-web: dist/personal-measure-web.tar.gz
|
||||||
|
mkdir -p temp-deploy/personal-measure-web-${VERSION}
|
||||||
|
tar xzf dist/personal-measure-web-${VERSION}.tar.gz -C temp-deploy/personal-measure-web-${VERSION}
|
||||||
|
aws s3 sync temp-deploy/personal-measure-web-${VERSION} s3://pm.jdb-labs.com/$(TARGET_ENV)/webroot
|
||||||
|
rm -r temp-deploy
|
||||||
|
|
||||||
|
deploy: deploy-api deploy-web
|
||||||
|
@ -1 +1 @@
|
|||||||
const PM_API_VERSION* = "0.1.0"
|
const PM_API_VERSION* = "0.2.0"
|
||||||
|
@ -7,3 +7,6 @@ User=pmapi
|
|||||||
WorkingDirectory=/home/pmapi
|
WorkingDirectory=/home/pmapi
|
||||||
ExecStart=/home/pmapi/personal_measure_api
|
ExecStart=/home/pmapi/personal_measure_api
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
10
deploy/PersonalMeasure_RoutingRules.xml
Normal file
10
deploy/PersonalMeasure_RoutingRules.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<RoutingRules>
|
||||||
|
<RoutingRule>
|
||||||
|
<Condition>
|
||||||
|
<KeyPrefixEquals>api</KeyPrefixEquals>
|
||||||
|
</Condition>
|
||||||
|
<Redirect>
|
||||||
|
<HostName>https://pmapi.jdbernard.com</HostName>
|
||||||
|
</Redirect>
|
||||||
|
</RoutingRule>
|
||||||
|
</RoutingRules>
|
76
deploy/doc.md
Normal file
76
deploy/doc.md
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
### Web App Hosting (static HTML)
|
||||||
|
|
||||||
|
Web app is deployed to an S3 bucket. Each top level directory in this bucket
|
||||||
|
represents a different deployed environment. For example:
|
||||||
|
|
||||||
|
s3://pm.jdb-labs.com
|
||||||
|
├── prod
|
||||||
|
│ ├── logs
|
||||||
|
│ │ └── cloudfront
|
||||||
|
│ └── webroot
|
||||||
|
│ ├── css
|
||||||
|
│ ├── img
|
||||||
|
│ ├── js
|
||||||
|
│ ├── index.html
|
||||||
|
│ └── ...
|
||||||
|
└── dev
|
||||||
|
├── logs
|
||||||
|
└── webroot
|
||||||
|
|
||||||
|
### API Hosting
|
||||||
|
|
||||||
|
API is served from razgriz:
|
||||||
|
* dev: https://pmapi-dev.jdb-labs.com (:80 -> :8281)
|
||||||
|
* prod: https://pmapi.jdb-labs.com (:80 -> :8280)
|
||||||
|
|
||||||
|
#### Server Setup Notes
|
||||||
|
|
||||||
|
The home folder of the `pmapi` user, like the S3 bucket, contains one folder
|
||||||
|
for each environment:
|
||||||
|
|
||||||
|
/home/pmapi
|
||||||
|
├── dev
|
||||||
|
│ ├── personal_measure_api
|
||||||
|
│ └── personal_measuer_api.config.json
|
||||||
|
└── prod
|
||||||
|
├── personal_measure_api
|
||||||
|
└── personal_measuer_api.config.json
|
||||||
|
|
||||||
|
As part of the automated deployment process, pmapi.jdb-labs.com has one systemd
|
||||||
|
service definitions for each environment. The sudoers file allows the `pmapi`
|
||||||
|
user to manage these without a password.
|
||||||
|
|
||||||
|
# Allow pmapi to manage the personal_measure_api service
|
||||||
|
pmapi ALL=NOPASSWD: /bin/systemctl stop personal_measure_api.prod.service
|
||||||
|
pmapi ALL=NOPASSWD: /bin/systemctl start personal_measure_api.prod.service
|
||||||
|
pmapi ALL=NOPASSWD: /bin/systemctl stop personal_measure_api.dev.service
|
||||||
|
pmapi ALL=NOPASSWD: /bin/systemctl start personal_measure_api.dev.service
|
||||||
|
|
||||||
|
two systemd
|
||||||
|
service definitions, one for
|
||||||
|
|
||||||
|
### Database
|
||||||
|
|
||||||
|
razgriz-db.jdb-labs.com RDS instance maintains databases for each environment:
|
||||||
|
* dev: `personal_measure_dev`
|
||||||
|
* prod: `personal_measure`
|
||||||
|
|
||||||
|
### Routing
|
||||||
|
|
||||||
|
CloudFront manages the routing of all of the external facing URLs.
|
||||||
|
|
||||||
|
https://pm.jdb-labs.com (CloudFront)
|
||||||
|
├── /api/<path>
|
||||||
|
│ └── https://pmapi.jdb-labs.com/api/
|
||||||
|
│ ├── nginx:80 --> nim/jester:8280
|
||||||
|
│ └── razgriz-db: database personal_measure
|
||||||
|
└── s3://pm.jdb-labs.com/prod/webroot (static HTML)
|
||||||
|
|
||||||
|
https://pm-dev.jdb-labs.com (CloudFront)
|
||||||
|
├── /api/<path>
|
||||||
|
│ └── https://pmapi-dev.jdb-labs.com/api/
|
||||||
|
│ ├── nginx:80 --> nim/jester:8281
|
||||||
|
│ └── razgriz-db: database personal_measure_dev
|
||||||
|
└── s3://pm.jdb-labs.com/dev/webroot (static HTML)
|
||||||
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
VUE_APP_PM_API_BASE=https://personal-measure.jdb-labs.com/api
|
|
||||||
VUE_APP_LOG_LEVEL=INFO
|
|
||||||
VUE_APP_API_LOG_LEVEL=ERROR
|
|
3
web/.env.production
Normal file
3
web/.env.production
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
VUE_APP_PM_API_BASE=https://pm.jdb-labs.com/api
|
||||||
|
VUE_APP_LOG_LEVEL=INFO
|
||||||
|
VUE_APP_API_LOG_LEVEL=ERROR
|
@ -1,4 +1,3 @@
|
|||||||
API_ADDR='localhost:8080'
|
|
||||||
API_LOG_LEVEL='WARN'
|
API_LOG_LEVEL='WARN'
|
||||||
LOG_LEVEL='TRACE'
|
LOG_LEVEL='TRACE'
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "personal-measure-web",
|
"name": "personal-measure-web",
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vue-cli-service serve",
|
"serve": "vue-cli-service serve",
|
||||||
"build": "vue-cli-service build",
|
"build": "vue-cli-service build --mode production",
|
||||||
"build-dev": "vue-cli-service build --mode development",
|
"build-dev": "vue-cli-service build --mode development",
|
||||||
"lint": "vue-cli-service lint",
|
"lint": "vue-cli-service lint",
|
||||||
"test:unit": "vue-cli-service test:unit"
|
"test:unit": "vue-cli-service test:unit"
|
||||||
|
@ -13,6 +13,7 @@ const logger = logService.getLogger('/app');
|
|||||||
})
|
})
|
||||||
export default class App extends Vue {
|
export default class App extends Vue {
|
||||||
|
|
||||||
|
public version = process.env.PM_VERSION;
|
||||||
private apiLogAppender!: ApiLogAppender;
|
private apiLogAppender!: ApiLogAppender;
|
||||||
private consoleLogAppender!: ConsoleLogAppender;
|
private consoleLogAppender!: ConsoleLogAppender;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ export class SimpleDetails extends Vue {
|
|||||||
@Prop() private measure!: Measure<MeasureConfig>;
|
@Prop() private measure!: Measure<MeasureConfig>;
|
||||||
@Prop() private measurements!: Array<Measurement<MeasurementMeta>>;
|
@Prop() private measurements!: Array<Measurement<MeasurementMeta>>;
|
||||||
|
|
||||||
private newMeasurement;
|
// private newMeasurement;
|
||||||
private moment = moment;
|
private moment = moment;
|
||||||
private chartOptions = {
|
private chartOptions = {
|
||||||
noData: { text: 'no data',
|
noData: { text: 'no data',
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
const merge = require('deepmerge');
|
||||||
|
const VERSION = {
|
||||||
|
'process.env': {
|
||||||
|
PM_VERSION: JSON.stringify(require('./package.json').version)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
devServer: {
|
devServer: {
|
||||||
proxy: {
|
proxy: {
|
||||||
@ -17,5 +24,11 @@ module.exports = {
|
|||||||
analyzerMode: 'static',
|
analyzerMode: 'static',
|
||||||
openAnalyzer: false
|
openAnalyzer: false
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
chainWebpack: config => {
|
||||||
|
config
|
||||||
|
.plugin('define')
|
||||||
|
.tap(args => merge(args, [VERSION]))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user