Open razzeee opened 2 years ago
Hello @razzeee - thanks for raising this, but I'm not sure I quite understand what the issue here is.
I tried reproducing the simplest way to verify that I thought of was overriding the DATABASE_URL
variable.
Here's what I did:
.env.defaults
has DATABASE_URL=file:./dev.db
DATABASE_URL=file:./other.db yarn rw prisma migrate dev
Which means that it's using the env var I set through the command line, not the default one.
Is this not the behaviour you are seeing?
It's not the behavior I'm seeing. But I think migrating worked at least I didn't see an error at that step, but on rw serve
I'm not sure if my docker file is breaking the env somehow, but I would be very surprised, as I did not change anything in that part of the code.
# ==
# Base
FROM node:16-alpine as base
WORKDIR /app
ARG NODE_ENV
ENV NODE_ENV=$NODE_ENV
ENV RUNTIME_ENV=$RUNTIME_ENV
ARG RUNTIME_ENV
ARG DATABASE_URL
ENV DATABASE_URL=$DATABASE_URL
ARG GITLAB_CLIENT_ID
ENV GITLAB_CLIENT_ID=$GITLAB_CLIENT_ID
ARG GITLAB_REDIRECT_URI
ENV GITLAB_REDIRECT_URI=$GITLAB_REDIRECT_URI
ARG GITLAB_AUTHORITY
ENV GITLAB_AUTHORITY=$GITLAB_AUTHORITY
ARG SITE_ID
ENV SITE_ID=$SITE_ID
ARG BASE_URL
ENV BASE_URL=$BASE_URL
COPY package.json package.json
COPY yarn.lock yarn.lock
COPY .yarn .yarn
COPY .yarnrc.yml .
COPY redwood.toml redwood.toml
COPY graphql.config.js graphql.config.js
COPY api/package.json api/package.json
COPY web/package.json web/package.json
RUN yarn install
COPY .env.defaults .
COPY run.sh .
# ==
# Build
FROM base as build
COPY api api
COPY web web
COPY scripts scripts
RUN yarn rw build api web
# ==
# Serve
FROM node:16-alpine as serve
WORKDIR /app
ARG DATABASE_URL
ENV DATABASE_URL=$DATABASE_URL
ARG GITLAB_AUTHORITY
ENV GITLAB_AUTHORITY=$GITLAB_AUTHORITY
COPY --from=build /app/run.sh /app/run.sh
RUN chmod +x ./run.sh
COPY --from=build /app/api/db/schema.prisma /app/api/db/schema.prisma
COPY --from=build /app/api/db/migrations /app/api/db/migrations
COPY --from=build /app/node_modules/.prisma /app/api/node_modules/.prisma
COPY --from=build /app/api/dist /app/api/dist
COPY --from=build /app/api/package.json /app/api/package.json
COPY --from=build /app/yarn.lock /app/api/yarn.lock
COPY --from=build /app/web/dist /app/web/dist
COPY --from=build /app/redwood.toml /app/redwood.toml
RUN yarn --cwd "api" --production install && \
yarn global add @redwoodjs/cli react react-dom prisma
EXPOSE 8910
ENTRYPOINT [ "./run.sh" ]
CMD [""]
run.sh
#!/bin/sh
# NOTE: Requires binaries. Install with:
# yarn global add @redwoodjs/api-server @redwoodjs/internal prisma
prisma migrate deploy --schema=/app/api/db/schema.prisma
rw serve
What's not working?
We had a setup working since around may.
Basically setting environment variables via gitlab and copying everything over to then build. Today our test and prod instance was not able to connect to the database anymore.
It turned out, that suddenly the entries in
.env.defaults
that we're also set via gitlab were overwritten by the default values.I'm not sure what changed or if this is even actionable. So feel free to close it. Just making sure it's documented.
How do we reproduce the bug?
.env.defaults
and command line.What's your environment? (If it applies)
Are you interested in working on this?