R
Railway

✋|help

Dockerfile working on local machine but not Railway

MMrxbox9811/24/2022
Here is my dockerfile
FROM rust:latest

ARG DATABASE_URL

WORKDIR /usr/src/pail

COPY Cargo.lock .
COPY Cargo.toml .
COPY docker_utils/dummy.rs .

# Change temporarely the path of the code
RUN sed -i 's|src/main.rs|dummy.rs|' Cargo.toml
# Build only deps
RUN cargo build --release
# Now return the file back to normal
RUN sed -i 's|dummy.rs|src/main.rs|' Cargo.toml

COPY . .

RUN cargo build --release

EXPOSE 8000

RUN touch .env

RUN echo "DATABASE_URL=$DATABASE_URL" >>.env

RUN echo "ROCKET_DATABASES='{db={url='$DATABASE_URL'}}'" >>.env

CMD ./target/release/pail
FROM rust:latest

ARG DATABASE_URL

WORKDIR /usr/src/pail

COPY Cargo.lock .
COPY Cargo.toml .
COPY docker_utils/dummy.rs .

# Change temporarely the path of the code
RUN sed -i 's|src/main.rs|dummy.rs|' Cargo.toml
# Build only deps
RUN cargo build --release
# Now return the file back to normal
RUN sed -i 's|dummy.rs|src/main.rs|' Cargo.toml

COPY . .

RUN cargo build --release

EXPOSE 8000

RUN touch .env

RUN echo "DATABASE_URL=$DATABASE_URL" >>.env

RUN echo "ROCKET_DATABASES='{db={url='$DATABASE_URL'}}'" >>.env

CMD ./target/release/pail
The .env DATABASE_URL is being properly injected and is in the .env as the build logs say, but in the deploy logs this is the error.
Error: database config error for pool named `db`
>> missing field `url`
Error: database config error for pool named `db`
>> missing field `url`
This error only happens when there is no .env The container works perfectly on my local machine and im wonder if I need to make special changes for it to work on Railway.
PPercy11/24/2022
Project ID: f742b766-da41-4ee1-9105-a414b1f90eb0
MMrxbox9811/24/2022
f742b766-da41-4ee1-9105-a414b1f90eb0 Resolved: For anyone else who may have this issue, I also had ROCKET_DATABASES in my environment variables which was causing the issue for some reason, remove it and it should work.

Looking for more? Join the community!