R
Railway10mo ago
zeebs

Disable Cache for build step on Railway

How do I disable cache for the build on railway. I've tried adding NIXPACKS_NO_CACHE=true or NIXPACKS_NO_CACHE=1 to the environment variables, but nothing changes. I really need to do this to debug an issue. Would be great to be able to do this without deleting and redeploying the instance
3 Replies
Brody
Brody10mo ago
docker layers will always be cached, this isn't something that can be turned off, but your problem is likely elsewhere. so what is the specific issue you are trying to debug?
zeebs
zeebs10mo ago
Hi @Brody ... I'm really pulling my hair out on this one! I'm deploying a Medusa backend and have extended the product service. Everything works on my local machine, however I get the following error on my production instance on Railway...
165.165.142.241 - - [09/Jan/2024:10:15:05 +0000] "GET /store/products HTTP/1.1" 500 86 "-" "PostmanRuntime/7.36.0"
running custom product listAndCount
error: productRepo.findWithRelationsAndCount is not a function
TypeError: productRepo.findWithRelationsAndCount is not a function
at ProductService.<anonymous> (/app/node_modules/@medusajs/medusa/dist/services/product.js:197:62)
at step (/app/node_modules/@medusajs/medusa/dist/services/product.js:59:23)
at Object.next (/app/node_modules/@medusajs/medusa/dist/services/product.js:40:53)
at /app/node_modules/@medusajs/medusa/dist/services/product.js:34:71
at new Promise (<anonymous>)
at __awaiter (/app/node_modules/@medusajs/medusa/dist/services/product.js:30:12)
at ProductService.listAndCount (/app/node_modules/@medusajs/medusa/dist/services/product.js:186:16)
at ProductService.listAndCount (/app/dist/services/product.js:38:28)
at /app/node_modules/@medusajs/medusa/dist/api/routes/store/products/list-products.js:335:50
at step (/app/node_modules/@medusajs/medusa/dist/api/routes/store/products/list-products.js:68:23)
165.165.142.241 - - [09/Jan/2024:10:15:05 +0000] "GET /store/products HTTP/1.1" 500 86 "-" "PostmanRuntime/7.36.0"
running custom product listAndCount
error: productRepo.findWithRelationsAndCount is not a function
TypeError: productRepo.findWithRelationsAndCount is not a function
at ProductService.<anonymous> (/app/node_modules/@medusajs/medusa/dist/services/product.js:197:62)
at step (/app/node_modules/@medusajs/medusa/dist/services/product.js:59:23)
at Object.next (/app/node_modules/@medusajs/medusa/dist/services/product.js:40:53)
at /app/node_modules/@medusajs/medusa/dist/services/product.js:34:71
at new Promise (<anonymous>)
at __awaiter (/app/node_modules/@medusajs/medusa/dist/services/product.js:30:12)
at ProductService.listAndCount (/app/node_modules/@medusajs/medusa/dist/services/product.js:186:16)
at ProductService.listAndCount (/app/dist/services/product.js:38:28)
at /app/node_modules/@medusajs/medusa/dist/api/routes/store/products/list-products.js:335:50
at step (/app/node_modules/@medusajs/medusa/dist/api/routes/store/products/list-products.js:68:23)
in trying to debug this issue, I have tried my best to reproduce the Railway deploy environment on my local machine: + Build with Nixpacks locally and run with Docker (works as expected locally) + Build with Docker using Dockerfile (modified Nixpacks output).... and build on Railway with same Dockerfile + still works as expected locally but throws above error on Railway I'm running out of ideas why this is happening. Dockerfile below for interest... '''
FROM ghcr.io/railwayapp/nixpacks:ubuntu-1702339400

ENTRYPOINT ["/bin/bash", "-l", "-c"]
WORKDIR /app/


COPY nixpkgs-bf744fe90419885eefced41b3e5ae442d732712d.nix nixpkgs-bf744fe90419885eefced41b3e5ae442d732712d.nix
RUN nix-env -if nixpkgs-bf744fe90419885eefced41b3e5ae442d732712d.nix && nix-collect-garbage -d


ARG CI NIXPACKS_METADATA NODE_ENV NPM_CONFIG_PRODUCTION SERVER_ONLY
ENV CI=$CI NIXPACKS_METADATA=$NIXPACKS_METADATA NODE_ENV=$NODE_ENV NPM_CONFIG_PRODUCTION=$NPM_CONFIG_PRODUCTION SERVER_ONLY=$SERVER_ONLY

# setup phase
# noop

# install phase
ENV NIXPACKS_PATH /app/node_modules/.bin:$NIXPACKS_PATH
COPY . /app/.
RUN npm i

# build phase
COPY . /app/.
RUN npm run build

RUN printf '\nPATH=/app/node_modules/.bin:$PATH' >> /root/.profile


# start
COPY . /app
CMD ["medusa migrations run && medusa start"]
FROM ghcr.io/railwayapp/nixpacks:ubuntu-1702339400

ENTRYPOINT ["/bin/bash", "-l", "-c"]
WORKDIR /app/


COPY nixpkgs-bf744fe90419885eefced41b3e5ae442d732712d.nix nixpkgs-bf744fe90419885eefced41b3e5ae442d732712d.nix
RUN nix-env -if nixpkgs-bf744fe90419885eefced41b3e5ae442d732712d.nix && nix-collect-garbage -d


ARG CI NIXPACKS_METADATA NODE_ENV NPM_CONFIG_PRODUCTION SERVER_ONLY
ENV CI=$CI NIXPACKS_METADATA=$NIXPACKS_METADATA NODE_ENV=$NODE_ENV NPM_CONFIG_PRODUCTION=$NPM_CONFIG_PRODUCTION SERVER_ONLY=$SERVER_ONLY

# setup phase
# noop

# install phase
ENV NIXPACKS_PATH /app/node_modules/.bin:$NIXPACKS_PATH
COPY . /app/.
RUN npm i

# build phase
COPY . /app/.
RUN npm run build

RUN printf '\nPATH=/app/node_modules/.bin:$PATH' >> /root/.profile


# start
COPY . /app
CMD ["medusa migrations run && medusa start"]
I've also pushed my working docker-image to ghcr.io and tried to deploy using this source-image... but can't seem to get the configuration right to work on Railway. Deployment fails and there are no logs to trouble-shoot why
Brody
Brody10mo ago
have you tried writing your own dockerfile, one that doesnt have anything to do with nixpacks or nix
Want results from more Discord servers?
Add your server