Determine Galaxy 'version' of my hosted code

On the galaxy.meteor.com overview page for my app, it nicely states which version (iteration?) has been deployed by galaxy…

Version 11 Deployed Yesterday at 12:09pm by …

Is there a programatic way I can obtain this number from my Meteor server code? It would be useful to quickly know I am not at ‘latest’ inside my deployed code.

1 Like

Sounds like a question for Galaxy support?

I was wondering the same and just found the answer

On the server you can ask for process.env.GALAXY_APP_VERSION_ID

2 Likes

Thanks @jamgold

I have wrapped your answer into a function that can be used on the client side as well

if (Meteor.isClient) {

   Meteor.call('getEnv', "GALAXY_APP_VERSION_ID", function(err, result) {
    console.info("Some CMS v" + result + ".");
  });

}


if (Meteor.isServer) {
  Meteor.methods({
    getEnv: function(node){
      // console.debug(process.env);
      return process.env[node];
    }
  }); 
}

Don’t do that ^^^

@williamli That may seem creative, but that is an incredibly insecure server side method that should not be installed in any application. Environment variables are often used to store secure information which should not be revealed to the client. In the case of GALAXY_APP_VERSION_ID, the value is relatively harmless. However, if someone were do to:

Meteor.call('getEnv', 'MONGO_URL', (error, result) => console.log(result));

…They will have the username and password to your Mongo database.

Please, think about security. There is no need to make this server method have access to every environment variable when it could just return the version number.

For the most part, this code shouldn’t really be necessary at all since Galaxy handles the updating of the server to the latest code automatically, and the Meteor client-side reloads itself to get the latest version when the server has been updated.

3 Likes

Is there any option to do this in a more secure way? :thinking: E.g. get the Galaxy version at the server side and pass only this information (version number) to the client…to have it displayed at the UI. Would be pretty helpful when testing with other people like end-users - who are not involved in the dev process but have to qualify bug reports. :slightly_smiling_face:

Thanks!

Regards

Sure, just change the above method so it cannot return any environment variable from the server, instead opting for only the single environment variable that’s needed. For example, consider a server method that does just:

Meteor.methods({
  getCurrentGalaxyAppVersionId() {
    return process.env['GALAXY_APP_VERSION_ID'];
  }
}); 
2 Likes

@abernix: Thank you very much for your reply. :raising_hand_man: I tried several times but had no luck. :slightly_frowning_face:

After checking the docs, etc. and other code examples I thought it makes sense to put the method you mentioned into “server/main.js”, code is like this:

import {Meteor} from 'meteor/meteor';

Meteor.methods({
    getCurrentGalaxyAppVersionId() {
    console.log("#CUSTOMLOG# Your Galaxy version is " + process.env['GALAXY_APP_VERSION_ID']);
        return process.env['GALAXY_APP_VERSION_ID'];
    }
});

Above log statement works fine, by the way.

Additionally I placed the client code in “imports/ui/body.js”, as I want to call
the method from body.html file:

import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
[..]

Template.body.helpers({
    getCurrentGalaxyAppVersionId: function () {
        Meteor.call('getCurrentGalaxyAppVersionId');
    }
});

Now body.html (yes, I use Blaze):

Galaxy Version: {{getCurrentGalaxyAppVersionId}}

What am I doing wrong? :thinking::neutral_face:

Thanks in advance!

Kind regards,
ffmit

Here is what I do:

// /server/main.js
Meteor.methods({
  getGalaxyVersion() {
    return process.env.GALAXY_APP_VERSION_ID;
  },
});
// /client/main.js
if (Meteor.isProduction) {
  Meteor.call('getGalaxyVersion', function (err, res) {
    if (err) {
      console.log(err);
    } else {
      console.log(res);
    }
  });
}

@vigorwebsolutions: I checked my code against mine but didn’t find a significant difference. How would you call your method from the template?

btw: I changed the body.helpers method like this (added “return”, which didn’t solve the problem:

getCurrentGalaxyAppVersionId() {
        return Meteor.call('getCurrentGalaxyAppVersionId');
    }

Best wishes

If you are trying to display it to the UI, maybe just assign it to a ReactiveVar?

Template.someTemplate.onCreated(function() {
  this.galaxyVersion = new ReactiveVar(false);
  
  Meteor.call('getGalaxyVersion', function (err, res) {
    if (err) {
      console.log(err);
    else {
      this.galaxyVersion.set(res);
    }
});

Template.someTemplate.helpers({
  galaxyVersion() {
    return Template.instance().galaxyVersion.get();
  },
});
1 Like

Hello @vigorwebsolutions,

I use Blaze as I’m a beginner, so I tried to integrate your code but had no luck yet.
Will come back tomorrow with code examples.

Thanks, so much, so far - great community! :+1: