mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-13 17:27:37 -05:00
Merge pull request #12 from natecarlson/natecarlson-modifications
Tweaks to make docker-test work with environmental variables only (ie, no code modifications)
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
docker-prod.sh
|
||||||
|
docker-test.sh
|
||||||
10
README.md
10
README.md
@@ -30,12 +30,20 @@ There are a lot of different components that make up the system. All of the serv
|
|||||||
|
|
||||||
You can run things in 2 different modes, `test` and `prod`. The big difference is that `prod` expects all of the calls to be https and gets cranky when they are not. I have gotten `test` to run fine on my laptop, so that is probably a good starting point.
|
You can run things in 2 different modes, `test` and `prod`. The big difference is that `prod` expects all of the calls to be https and gets cranky when they are not. I have gotten `test` to run fine on my laptop, so that is probably a good starting point.
|
||||||
|
|
||||||
|
Currently, both `test` and `prod` expect to use S3-based storage instead of local storage. Switching to use local storage would be relatively easy - but for the sake of testing, let's just say use something S3-compatible. Make sure that ~/.aws/credentials has the credentials you'd like to use with your S3-compatible storage provider.. IE:
|
||||||
|
```
|
||||||
|
[default]
|
||||||
|
aws_access_key_id = [..]
|
||||||
|
aws_secret_access_key = [..]
|
||||||
|
```
|
||||||
|
|
||||||
|
Copy docker-test.sh.example to docker-test.sh, and/or docker-prod.sh.example to docker-prod.sh.
|
||||||
|
|
||||||
`./docker-test.sh` - sets up docker-compose to run with the correct environment variables for testing
|
`./docker-test.sh` - sets up docker-compose to run with the correct environment variables for testing
|
||||||
|
|
||||||
`./docker-prod.sh` - sets up docker-compose to run with the correct environment variables for production
|
`./docker-prod.sh` - sets up docker-compose to run with the correct environment variables for production
|
||||||
|
|
||||||
Fill out the Environment variables in both these files. You don't need to worry about the Stripe stuff, since that is dormant.
|
Fill out the Environment variables in both these files. S3_PROFILE should match the profile that is defined in the aws/credentials file. You don't need to worry about the Stripe stuff, since that is dormant.
|
||||||
|
|
||||||
If you are doing frontend work, you can turn off the de-obfuscation. To do this, edit the Dockerfile for the server you are working with. Change the CMD to:
|
If you are doing frontend work, you can turn off the de-obfuscation. To do this, edit the Dockerfile for the server you are working with. Change the CMD to:
|
||||||
`CMD ["npm", "run", "start:dev"]` Just remember to turn it off when you make the code public.
|
`CMD ["npm", "run", "start:dev"]` Just remember to turn it off when you make the code public.
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ var config = require('../config/config.json');
|
|||||||
|
|
||||||
var media_server = process.env['MEDIA_SERVER'] != null ? process.env['MEDIA_SERVER'] : 'https://media.openmhz.com';
|
var media_server = process.env['MEDIA_SERVER'] != null ? process.env['MEDIA_SERVER'] : 'https://media.openmhz.com';
|
||||||
var s3_endpoint = process.env['S3_ENDPOINT'] != null ? process.env['S3_ENDPOINT'] : 's3.us-west-1.wasabisys.com';
|
var s3_endpoint = process.env['S3_ENDPOINT'] != null ? process.env['S3_ENDPOINT'] : 's3.us-west-1.wasabisys.com';
|
||||||
|
var s3_bucket = process.env['S3_BUCKET'] != null ? process.env['S3_BUCKET'] : 'openmhz-west';
|
||||||
var s3_profile = process.env['S3_PROFILE'] != null ? process.env['S3_PROFILE'] : 'wasabi-account';
|
var s3_profile = process.env['S3_PROFILE'] != null ? process.env['S3_PROFILE'] : 'wasabi-account';
|
||||||
|
|
||||||
const wasabi = require('aws-sdk');
|
const wasabi = require('aws-sdk');
|
||||||
@@ -126,23 +127,21 @@ process.nextTick(function() {
|
|||||||
var local_path = "/" + shortName + "/" + time.getFullYear() + "/" + (time.getMonth() + 1) + "/" + time.getDate() + "/";
|
var local_path = "/" + shortName + "/" + time.getFullYear() + "/" + (time.getMonth() + 1) + "/" + time.getDate() + "/";
|
||||||
var target_file = base_path + local_path + path.basename(req.file.originalname);
|
var target_file = base_path + local_path + path.basename(req.file.originalname);
|
||||||
var object_key = "media/" + shortName + "-" + talkgroupNum + "-" + startTime + ".m4a";
|
var object_key = "media/" + shortName + "-" + talkgroupNum + "-" + startTime + ".m4a";
|
||||||
//var endpoint = 'https://s3.amazonaws.com/openmhz/';
|
|
||||||
//var endpoint = 'https://s3.wasabisys.com/openmhz/';
|
|
||||||
var endpoint = s3_endpoint;
|
|
||||||
var bucket = 'openmhz'
|
|
||||||
//var url = 'https://openmhz.nyc3.cdn.digitaloceanspaces.com/' + object_key;
|
|
||||||
|
|
||||||
var url = endpoint + object_key;
|
var endpoint = s3_endpoint;
|
||||||
//var url = 'https://s3.wasabisys.com/openmhz/' + object_key;
|
var bucket = s3_bucket;
|
||||||
//var url = 'https://s3.amazonaws.com/openmhz/' + object_key;
|
|
||||||
var objectStore = true;
|
|
||||||
if (item.plan && (item.plan.type == "pro")) {
|
if (item.plan && (item.plan.type == "pro")) {
|
||||||
|
// If a pro plan, use local storage
|
||||||
|
// TODO: Why?
|
||||||
url = media_server + local_path + talkgroupNum + "-" + startTime + ".m4a";
|
url = media_server + local_path + talkgroupNum + "-" + startTime + ".m4a";
|
||||||
objectStore = false;
|
objectStore = false;
|
||||||
|
} else {
|
||||||
|
// If not a pro plan, use S3 storage
|
||||||
|
var url = 'https://' + s3_endpoint + "/" + s3_bucket + "/" + object_key;
|
||||||
|
var objectStore = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var call = new Call({
|
var call = new Call({
|
||||||
shortName: shortName,
|
shortName: shortName,
|
||||||
talkgroupNum: talkgroupNum,
|
talkgroupNum: talkgroupNum,
|
||||||
@@ -222,7 +221,7 @@ process.nextTick(function() {
|
|||||||
});*/
|
});*/
|
||||||
|
|
||||||
var wasabiParams = {
|
var wasabiParams = {
|
||||||
Bucket: 'openmhz-west',
|
Bucket: s3_bucket,
|
||||||
Key: object_key,
|
Key: object_key,
|
||||||
Body: wasabiSrc,
|
Body: wasabiSrc,
|
||||||
ACL: 'public-read'
|
ACL: 'public-read'
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ services:
|
|||||||
- FREE_PLAN_ARCHIVE
|
- FREE_PLAN_ARCHIVE
|
||||||
- PRO_PLAN_ARCHIVE
|
- PRO_PLAN_ARCHIVE
|
||||||
- S3_ENDPOINT
|
- S3_ENDPOINT
|
||||||
|
- S3_BUCKET
|
||||||
- S3_PROFILE
|
- S3_PROFILE
|
||||||
volumes:
|
volumes:
|
||||||
- "${MEDIA}:/home/app/trunk-server-backend/media"
|
- "${MEDIA}:/home/app/trunk-server-backend/media"
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ export SOCKET_SERVER="wss://socket.${DOMAIN_NAME}"
|
|||||||
export ACCOUNT_SERVER="${PROTOCOL}account.${DOMAIN_NAME}"
|
export ACCOUNT_SERVER="${PROTOCOL}account.${DOMAIN_NAME}"
|
||||||
export COOKIE_DOMAIN=".${DOMAIN_NAME}"
|
export COOKIE_DOMAIN=".${DOMAIN_NAME}"
|
||||||
export S3_PROFILE='wasabi-account'
|
export S3_PROFILE='wasabi-account'
|
||||||
export S3_ENPOINT='s3.us-west-1.wasabisys.com'
|
export S3_ENDPOINT='s3.us-west-1.wasabisys.com'
|
||||||
|
export S3_BUCKET='openmhz-west'
|
||||||
export SITE_NAME="OpenMHz"
|
export SITE_NAME="OpenMHz"
|
||||||
export ADMIN_EMAIL="luke@openmhz.com"
|
export ADMIN_EMAIL="luke@openmhz.com"
|
||||||
export FREE_PLAN=0
|
export FREE_PLAN=0
|
||||||
@@ -19,7 +19,8 @@ export COOKIE_DOMAIN=".${DOMAIN_NAME}"
|
|||||||
export SITE_NAME="OpenMHz"
|
export SITE_NAME="OpenMHz"
|
||||||
export ADMIN_EMAIL="admin@email.com"
|
export ADMIN_EMAIL="admin@email.com"
|
||||||
export S3_PROFILE='default'
|
export S3_PROFILE='default'
|
||||||
export S3_ENPOINT='s3.us-west-1.wasabisys.com'
|
export S3_ENDPOINT='s3.us-west-1.wasabisys.com'
|
||||||
|
export S3_BUCKET='openmhz-test'
|
||||||
export FREE_PLAN=0
|
export FREE_PLAN=0
|
||||||
export PRO_PLAN=10
|
export PRO_PLAN=10
|
||||||
export FREE_PLAN_PRICE=0
|
export FREE_PLAN_PRICE=0
|
||||||
@@ -5,6 +5,7 @@ FROM node:8.11
|
|||||||
|
|
||||||
|
|
||||||
ENV HOME=/home/app
|
ENV HOME=/home/app
|
||||||
|
ENV NODE_OPTIONS="--max_old_space_size=8000"
|
||||||
|
|
||||||
RUN mkdir -p /home/app
|
RUN mkdir -p /home/app
|
||||||
COPY ./package.json /tmp
|
COPY ./package.json /tmp
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ RUN apt-get update \
|
|||||||
|
|
||||||
# Add main NGINX config
|
# Add main NGINX config
|
||||||
COPY *.conf /etc/nginx/
|
COPY *.conf /etc/nginx/
|
||||||
COPY htpasswd /etc/nginx/
|
|
||||||
COPY ${STAGE}/certs/ /etc/nginx/certs/
|
COPY ${STAGE}/certs/ /etc/nginx/certs/
|
||||||
|
|
||||||
# Add virtual hosts
|
# Add virtual hosts
|
||||||
|
|||||||
Reference in New Issue
Block a user