Skip to content

Commit 5df2c11

Browse files
committed
nginx: fix bad tgz storage path
Because of the extra /-/ in the path, nginx was failing to create the necessary subdirectories to store the file in. Additionally, the parent folder did not exist, so make sure all the storage paths used are created at container startup.
1 parent 038f9b7 commit 5df2c11

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

entrypoint.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export MAXAGE=${MAXAGE:-5m}
1616
# necessary because nginx requires a resolver when upstreams are dynamic
1717
dnsmasq --listen-address=127.0.0.1 --user=root
1818

19-
# in case it hasn't been created as a tmpfs already
20-
mkdir -p /tmp/npm
19+
# in case /tmp/npm hasn't been created as a tmpfs already
20+
mkdir -p /tmp/npm/{store,temp,cache}
21+
# nginx runs as uid nobody and it needs write access
22+
chown -R nobody /tmp/npm
2123

2224
exec /usr/local/openresty/bin/openresty -c /nginx.conf $*

nginx.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ http {
3737
set_by_lua_block $npm_config_registry {
3838
return ngx.shared.npmConfig:get('npm_config_registry')
3939
}
40-
location ~ ^/.*\.tgz$ {
40+
location ~ ^/(.+)/-/(.+\.tgz)$ {
4141
root /tmp/npm/store;
42-
try_files $uri @fetch-tgz;
42+
try_files /$1/$2 @fetch-tgz;
4343
}
4444
location / {
4545
set $ephemeralCacheStatus '-';
@@ -70,7 +70,7 @@ http {
7070
proxy_pass $npm_config_registry;
7171
proxy_buffering on;
7272
proxy_buffers 512 512k;
73-
proxy_store on;
73+
proxy_store /tmp/npm/store/$1/$2;
7474
proxy_store_access user:rw group:rw all:r;
7575
proxy_temp_path /tmp/npm/temp;
7676
root /tmp/npm/store;

0 commit comments

Comments
 (0)