a year ago
The main error as I understand it:
#9 [stage-0 6/10] COPY target/CCODE.pattern.rest.war ROOT.war
Attempting to follow Railway's Python provider example (https://docs.railway.app/guides/dockerfiles), I used the cache directory as provided in the Java provider:
Line 66:build.add_cache_directory(".m2/repository");
https://github.com/railwayapp/nixpacks/blob/main/src/providers/java.rs
I attempted to follow the build order and paths from tomcat's Dockerfile:
https://github.com/docker-library/tomcat/blob/master/10.1/jdk21/temurin-jammy/Dockerfile
My build has failed around 60 times now. I've tried variations of paths and order of build steps. Can someone tell me what I'm doing wrong?
(I'll add the Dockerfile in a reply post)
[Region: us-west1]
=========================
Using Detected Dockerfile
=========================
#0 building with "default" instance using docker driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 1.07kB done
#1 DONE 0.0s
#2 [internal] load metadata for docker.io/library/tomcat:10.1-jdk21-temurin
#2 DONE 0.3s
#3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s
#4 [internal] load build context
#4 transferring context: 2B done
#4 DONE 0.0s
#5 [stage-0 5/10] RUN apt-get update && apt-get install -y maven
#5 CACHED
#6 [stage-0 2/10] RUN ls -la
#6 CACHED
#7 [stage-0 3/10] WORKDIR /usr/local/tomcat/webapps
#7 CACHED
#8 [stage-0 4/10] RUN rm -rf ./*
#8 CACHED
#9 [stage-0 6/10] COPY target/CCODE.pattern.rest.war ROOT.war
#9 ERROR: failed to calculate checksum of ref 9979074f-b6e3-4de1-849c-8a28c9e8f676::7nfwo88qpzluh0pd9c8duyous: failed to walk /var/lib/docker/tmp/buildkit-mount220413647/target: lstat /var/lib/docker/tmp/buildkit-mount220413647/target: no such file or directory
#10 [stage-0 1/10] FROM docker.io/library/tomcat:10.1-jdk21-temurin@sha256:ae222bd36d0719037741b36750376da8d4b07c1f47108ddb340966ae47b5995b
#10 resolve docker.io/library/tomcat:10.1-jdk21-temurin@sha256:ae222bd36d0719037741b36750376da8d4b07c1f47108ddb340966ae47b5995b done
#10 sha256:ae222bd36d0719037741b36750376da8d4b07c1f47108ddb340966ae47b5995b 979B / 979B done
ⓘ Deployment information is only viewable by Project members and Railway admins.
25 Replies
a year ago
Here's the Dockerfile as a txt and pasted. Any help would be greatly appreciated.
FROM tomcat:10.1-jdk21-temurin
ARG RAILWAY_PUBLIC_DOMAIN
ARG RAILWAY_PRIVATE_DOMAIN
ARG RAILWAY_PROJECT_NAME
ARG RAILWAY_ENVIRONMENT_NAME
ARG RAILWAY_SERVICE_NAME
ARG RAILWAY_PROJECT_ID
ARG RAILWAY_ENVIRONMENT_ID
ARG RAILWAY_SERVICE_ID
ENV RAILWAY_PUBLIC_DOMAIN=$RAILWAY_PUBLIC_DOMAIN \
RAILWAY_PRIVATE_DOMAIN=$RAILWAY_PRIVATE_DOMAIN \
RAILWAY_PROJECT_NAME=$RAILWAY_PROJECT_NAME \
RAILWAY_ENVIRONMENT_NAME=$RAILWAY_ENVIRONMENT_NAME \
RAILWAY_SERVICE_NAME=$RAILWAY_SERVICE_NAME \
RAILWAY_PROJECT_ID=$RAILWAY_PROJECT_ID \
RAILWAY_ENVIRONMENT_ID=$RAILWAY_ENVIRONMENT_ID \
RAILWAY_SERVICE_ID=$RAILWAY_SERVICE_ID
WORKDIR /usr/local/tomcat/webapps
RUN rm -rf ./*
RUN apt-get update && \
apt-get install -y maven
COPY target/CCODE.pattern.rest.war ROOT.war
RUN ls -la
WORKDIR /app
RUN --mount=type=cache,id=s/cbcd6488-98bc-4b7a-98d0-a1209477cc8e-/root/.m2,target=/root/.m2 \
mvn -DskipTests clean install
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/*
CMD ["catalina.sh", "run"]
Attachments
a year ago
I've also been trying to get some visibility with ls and tree commands, if anyone knows if there's a way to reveal the file structure that would also be very helpful.
a year ago
Hi Brody, without changing the "RUN --mount=type=cache…" instruction, I've tried adding variations of "-docker build --no-cache ." to Railway's Custom Build Command without success.
a year ago
I'm not sure what the structure or limitations around Docker are, I am a beginner user.
a year ago
Can you tell me how to do that? I've tried removing the --mount command and the Custom Build Command mentioned earlier to no avail.
a year ago
Yes
a year ago
``` FROM tomcat:10.1-jdk21-temurin
ARG RAILWAYPUBLICDOMAIN
ARG RAILWAYPRIVATEDOMAIN
ARG RAILWAYPROJECTNAME
ARG RAILWAYENVIRONMENTNAME
ARG RAILWAYSERVICENAME
ARG RAILWAYPROJECTID
ARG RAILWAYENVIRONMENTID
ARG RAILWAYSERVICEID
ENV RAILWAYPUBLICDOMAIN=$RAILWAYPUBLICDOMAIN \
RAILWAYPRIVATEDOMAIN=$RAILWAYPRIVATEDOMAIN \
RAILWAYPROJECTNAME=$RAILWAYPROJECTNAME \
RAILWAYENVIRONMENTNAME=$RAILWAYENVIRONMENTNAME \
RAILWAYSERVICENAME=$RAILWAYSERVICENAME \
RAILWAYPROJECTID=$RAILWAYPROJECTID \
RAILWAYENVIRONMENTID=$RAILWAYENVIRONMENTID \
RAILWAYSERVICEID=$RAILWAYSERVICEID
WORKDIR /usr/local/tomcat/webapps
RUN rm -rf ./*
RUN apt-get update && \
apt-get install -y maven
COPY target/CCODE.pattern.rest.war ROOT.war
WORKDIR /app
RUN mvn -DskipTests clean install
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/*
CMD ["catalina.sh", "run"]
```
Attachments
a year ago
I know I'm doing something wrong, been reading forums and documentation and scratching my head all day about it.
a year ago
Just clutter at the moment, I think I was hoping to get some visibility.
a year ago
```
8 [5/8] COPY target/CCODE.pattern.rest.war ROOT.war
8 ERROR: failed to calculate checksum of ref 0eb318fa-722a-4cac-8d08-f9b3871d930d::m7za1wtpzsjiacst6sjn6nwmh: failed to walk /var/lib/docker/tmp/buildkit-mount1968124015/target: lstat /var/lib/docker/tmp/buildkit-mount1968124015/target: no such file or directory
9 [1/8] FROM docker.io/library/tomcat:10.1-jdk21-temurin@sha256:ae222bd36d0719037741b36750376da8d4b07c1f47108ddb340966ae47b5995b
9 resolve docker.io/library/tomcat:10.1-jdk21-temurin@sha256:ae222bd36d0719037741b36750376da8d4b07c1f47108ddb340966ae47b5995b done
9 sha256:ae222bd36d0719037741b36750376da8d4b07c1f47108ddb340966ae47b5995b 979B / 979B done
9 sha256:fca42eb4b55005efff2b87d5efca5bb311427ffa161099baa4ae748315b87d35 13.13kB / 13.13kB done
9 sha256:9f7f76109c8e077f7c52649629e04366539c48703d6589c31685de2bacb51065 2.00kB / 2.00kB done
9 CANCELED
[5/8] COPY target/CCODE.pattern.rest.war ROOT.war:
Dockerfile:28
26 | apt-get install -y maven
27 |
28 | >>> COPY target/CCODE.pattern.rest.war ROOT.war
29 |
30 | WORKDIR /app
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 0eb318fa-722a-4cac-8d08-f9b3871d930d::m7za1wtpzsjiacst6sjn6nwmh: failed to walk /var/lib/docker/tmp/buildkit-mount1968124015/target: lstat /var/lib/docker/tmp/buildkit-mount1968124015/target: no such file or directory```
a year ago
What makes you think the file you are copying exists or that you have the correct path?
a year ago
It seems when Maven performs install, the /target/ directory is not in the location my path is telling it it should be. I can get it work locally, with Maven creating /target/ via "mvn clean install", but I don't know how to locate it in Railway prod. I believe I am adding the correct paths as advised by the Java provider as linked above.
a year ago
Do you know how I can ensure the path is correct? Documentation or a working project would be very appreciated. The tree of my project after "mvn clean install" looks like this, the paths for the COPY command appearing to be in the correct location.
```$ tree -L 2
.
├── Dockerfile
├── Dockerfile.txt
├── gen
│ ├── api
│ ├── build.gradle
│ ├── build.sbt
│ ├── docs
│ ├── git_push.sh
│ ├── gradle
│ ├── gradle.properties
│ ├── gradlew
│ ├── gradlew.bat
│ ├── pom.xml
│ ├── README.md
│ ├── settings.gradle
│ └── src
├── org.ccode.pattern.rest.iml
├── pom.xml
├── README.md
├── src
│ └── main
├── target
│ ├── CCODE.pattern.rest
│ ├── CCODE.pattern.rest-classes.jar
│ ├── CCODE.pattern.rest.war
│ ├── classes
│ ├── generated-sources
│ ├── maven-archiver
│ └── maven-status
└── tomcat.8080
└── work
15 directories, 16 files
```
a year ago
Have you tried COPY ./target/[CCODE.pattern.rest](CCODE.pattern.rest).war ROOT.war
a year ago
Would I copy that exactly as-is with the brackets? I tried adding "./" just now with the same error:
Dockerfile:28
-------------------
26 | apt-get install -y maven
27 |
28 | >>> COPY ./target/CCODE.pattern.rest.war ROOT.war
29 |
30 | WORKDIR /app
-------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref d9d17188-8002-4955-b97f-784cd897816e::26q91y7egjiy4remwqvrmw9is: failed to walk /var/lib/docker/tmp/buildkit-mount2733897827/target: lstat /var/lib/docker/tmp/buildkit-mount2733897827/target: no such file or directory
a year ago
For anyone reading this: I worked around this issue by building the /target/ directory locally then pushing it up in git, as opposed to insisting Maven build in Railway.
a year ago
You were trying to copy the file into the image so I had assumed the file you were trying to copy was in fact there, I'm now finding out this wasn't the case, in the future please provide more context, help me help you basically.