matteofigus on master
0.48.18 changelog (compare)
matteofigus on master
0.48.18 changelog (compare)
matteofigus on v0.48.18
matteofigus on v0.48.18
matteofigus on master
Add support for custom keepAliv… Merge pull request #1184 from d… (compare)
matteofigus on master
Add support for custom keepAliv… Merge pull request #1184 from d… (compare)
Hello.
it's been a while since i last posted here!.
This is probably an easy question for you guys.
Some Context: You know there is this feature about the oc-registry where is able to serve the static files from a component. You can configure the path from the static files through the package.json.
Well the thing is , while the oc registry is ran locally (through the oc dev ). Is able to serve these files, BUT, whenever i run the oc-registry NOT locally, is not able to get these files.
Hello @matteofigus , Thanks for the fast response.
So i tested your component locally and i could access to it by using
http://localhost:3030/static-image/1.0.0/static/images/oc.png
but this route is not available if i publish it to a real oc-registry and the only way to get the static path is to use Javascript to retrieve it from the server.js and while this is convenient when you are able to use Javascript, is not going to work on css Files... for fonts and images, OR i am missing something ?
router.use(
'/:componentName/:componentVersion/static/*',
proxy(`${conf.storage.options.path}${conf.storage.options.componentsDir}`, {
proxyReqPathResolver: function (req) {
return `${conf.storage.options.path}${conf.storage.options.componentsDir}/${req.params.componentName}/${req.params.componentVersion}/${req.params[0]}`;
},
proxyReqOptDecorator: function (proxyReqOpts, originalReq) {
proxyReqOpts.rejectUnauthorized = false
return proxyReqOpts;
}
})
);
The issue is that you are using the same instance for hosting both static and registry which is kind of an anti pattern. OC is designed to store anything static in the cdn during publishing to solve that problem. With the approach you posted you are proxying to the cdn but if you use context.staticPath you’ll just use the cdn base urls making unnecessary to setup the proxy
Got you. Nevermind about what i posted then, i think it just works for our case scenario.
hi @matteofigus @kmcrawford @nickbalestra thank you so much for your work ! I hope you will be able to answer one question
We are trying to deploy registry to AWS S3 using Jenkins, Docker and K8s.
here is how our config looks like, just standard:
'use strict';
require('dotenv').config();
const Registry = require('oc').Registry;
const configuration = {
baseUrl:'our-url-here',
port: 3000, #do we need to have this port be the same as where baseUrl running?
refreshInterval: 600,
pollingInterval: 5,
publishAuth: {
type: 'basic',
username: 'a',
password: 'b'
},
s3: {
key: '**',
secret: '**',
bucket: 'bucket-name',
region: 'region',
path: `path`,
componentsDir: 'components'
},
dependencies: [],
templates: [],
};
const registry = new Registry(configuration);
registry.start(function (err, app) {
if (err) {
console.log('Registry not started: ', err);
process.exit(1);
}
});
And we are getting this error:
Registry not started: components_list_save
I found where is this error coming from and looks like it can't find folder "components" in the bucket or list of components in the bucket. Components folder It exists and I can upload things there from command line. So I'm getting this error because access to this bucket restricted just to a certain user ? (even we provide aws s3 secrets and key for this user in the config file )...
If yes - is there any work around to have bucket be restricted just for a certain users and to not make it public? or it should be always public and reachable to make "oc publish" work and be able to read from the registry?
It lives under company AWS account and security won't allow it to be public, so maybe you faced the same issue or can suggest a solution?
Thank you
@matteofigus wow ;) I didn't expect to receive immediate answer from you, thank you!
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "OurSid",
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::bucket-name",
"arn:aws:s3:::bucket-name/*"
]
}
]
}
Hmm, weird. Above you can see the policy for a user so he can perform every action with this bucket
I tried manually write to the bucket using this credentials and it works, but during the deployment registry won't start and still getting this error (( so you think issue is with access and there is no need for additional configuration ?
I apologize for very theoretical questions ;)
@matteofigus here is bucket policy(allow all actions for user above)
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "statement1",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::account-id:user/user-name"
},
"Action": "s3:*",
"Resource": "arn:aws:s3:::our-bucket-name"
},
{
"Sid": "statement2",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::account-id:user/user-name"
},
"Action": "s3:*",
"Resource": "arn:aws:s3:::our-bucket-name/*"
}
]
}
Is something looks weird to you ?
error occurred when publishing to a registry {}
@matteofigus Hi! We use SSR only and I think I'll need to use you suggestion and override public part. So after in my server.js I should have something like this when I use storage adapter?
const oc = require('oc');
const s3 = require('oc-s3-storage-adapter');
let config = {
baseUrl: 'my url',
port: 3000,
refreshInterval: 600,
pollingInterval: 5,
templates: [require('oc-template-jade')],
storage: {
adapter: s3,
options: {
key: 'my key',
secret: 'my secret',
bucket: 'my bucket name',
region: 'us-east-2',
componentsDir: 'components',
sslEnabled: false,
s3ForcePathStyle: true,
path - > ??
debug: true,
endpoint: 'http://localhost:8080'
}
},
env: { name: 'production' }
};
let registry = new oc.Registry(config);
registry.start(function(err, app){
if(err) {
console.log('Registry not started: ', err);
process.exit(1);
}
});
I was looking for some documentation for storage adapters, maybe you have some examples? The most part is self explanatory, but maybe I'll miss something accidentally or I need more configuration under 'options'...
client.renderComponents()
but it makes rendering a little slower, so I hope I'm on the right track because I don't have any other option in my mind.@kmcrawford wow thank you! I'm trying to do something like that in NodeJS and express.js router, so far can't get through access denied message.
My initial idea was to do following:
const AWS = require('aws-sdk')
const s3 = new AWS.S3()
AWS.config.update({accessKeyId: 'id', secretAccessKey: 'key'})
const myBucket = 'bucket-name'
const signedUrlExpireSeconds = 60 * 5 <-- just a test
const url = s3.getSignedUrl('getObject', {
Bucket: myBucket,
Key: "/",
Expires: signedUrlExpireSeconds
})
console.log(url)
And then pass it to the client = to have something like that:const client = new Client({
registries: {
serverRendering: pre-signed url here <---
},
})
maybe I'm on the wrong track, will see