Skip to content

Commit

Permalink
Merge pull request #1 from internetarchive/production
Browse files Browse the repository at this point in the history
.mem.gz files cant be application/javascript mime types. make nomad review app cluster use for testing easier
  • Loading branch information
traceypooh authored Apr 9, 2024
2 parents e7c61bf + c5e8ae2 commit 93a6b40
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ FROM nginx:alpine

WORKDIR /usr/share/nginx/html

RUN rm -f index.html && \
# xxx not great for files that dont end like: .js.gz .wasm.gz
sed -i 's/js;/js gz;/' /etc/nginx/mime.types
RUN rm -f index.html

COPY default.conf /etc/nginx/conf.d/

Expand Down
4 changes: 3 additions & 1 deletion default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ server {
add_header Vary Origin;
}

# customization - like above but with `Content-Encoding` header
# customization - like 1st location, but with `Content-Type` & `Content-Encoding` headers
location ~\.(js|wasm)\.gz$ {
root /usr/share/nginx/html;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
add_header Access-Control-Allow-Headers Accept-Encoding,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,DNT,Pragma,Range,X-Requested-With;
add_header Vary Origin;

types { }
default_type application/javascript;
add_header Content-Encoding gzip;
}

Expand Down
14 changes: 10 additions & 4 deletions loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/* eslint-disable */
var Module = null;

(function (Promise) {
Expand Down Expand Up @@ -710,8 +711,13 @@ var Module = null;
// NOTE: deliberately use cors.archive.org since this will 302 rewrite to iaXXXXX.us.archive.org/XX/items/...
// and need to keep that "artificial" extra domain-ish name to avoid CORS issues with IE/Safari (tracey@archive)
var get_cors_url = function(item, path) {
if (item === 'emularity-engine' || item === 'emularity-config' || item === 'emularity-bios')
return '//' + item + '.ux-b.archive.org/' + (path ? '/' + path : '');
if (item === 'emularity-engine' || item === 'emularity-config' || item === 'emularity-bios') {
// allow optional testing CGI arg to hit the review app test cluster
// (helpful for testing out pre-production code & files)
var prefix = location.search.indexOf('?devao=1') < 0 ? '' : 'internetarchive-';
var domain = location.search.indexOf('?devao=1') < 0 ? 'ux-b.archive.org' : 'dev.archive.org';
return '//' + prefix + item + '.' + domain + '/' + path;
}

return '//cors.archive.org/cors/' + item + (path ? '/' + path : '');
}
Expand Down Expand Up @@ -1927,11 +1933,11 @@ var Module = null;
for (var i = 1; i < parts.length; i++) {
var path = '/'+ parts.slice(0, i).join('/');
if (!deltaFS.existsSync(path)) {
deltaFS.mkdirSync(path, 0777);
deltaFS.mkdirSync(path, 0777); // 0o777 strict xxx
}
}
}
deltaFS.writeFileSync(filename, new Buffer(data), null, flag_w, 0644);
deltaFS.writeFileSync(filename, new Buffer(data), null, flag_w, 0644); // 0o644 strict xxx
}
};
}
Expand Down

0 comments on commit 93a6b40

Please sign in to comment.