Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

envOr not picking up environment variable from docker #663

Closed
jwaldner opened this issue Sep 30, 2021 · 1 comment
Closed

envOr not picking up environment variable from docker #663

jwaldner opened this issue Sep 30, 2021 · 1 comment

Comments

@jwaldner
Copy link

jwaldner commented Sep 30, 2021

Description

[NEVER MIND FIXED WITH A WAIT SCRIPT]

I have docker environment variables that I have confirmed on the container.

I am using this in my database.yml file

development:
dialect: postgres
database: {{ envOr "POSTGRES_DB" "movie_database" }}
user: {{ envOr "POSTGRES_USER" "movie_user" }}
password: {{ envOr "POSTGRES_PASSWORD" "magic_ticket" }}
host: {{ envOr "POSTGRES_HOST" "localhost" }}
pool: 5

should I be able to use the detailed setup with envOr?

it is able to pull out the default values when I run locally without a docker container,

this is my .env

database.env

POSTGRES_USER=movie_user
POSTGRES_PASSWORD=magic_ticket
POSTGRES_DB=movie_database
POSTGRES_PORT=6543
POSTGRES_HOST=db

I can echo each of these but only the defaults are used for my migrations

Am I doing something silly?

oh, and if comment out soda migrate in the docker file and shell into the container the migrations work ???

but docker compose uses the default host of localhost and not db
the log shows:
#29 0.625 [POP] 2021/09/30 18:07:33 info - 0.0010 seconds
#29 0.625 Error: Migrator: problem creating schema migrations: couldn't start a new transaction: could not create new transaction: failed to connect to host=localhost user=movie_user database=movie_database: dial error (dial tcp [::1]:5432: connect: cannot assign requested address)

#29 0.625 [POP] 2021/09/30 18:07:33 warn - Migrator: unable to dump schema: exec: "pg_dump": executable file not found in $PATH

it shows localhost instead of the db I expect...pretty new to all this so it may not be a bug;

this is my docker file

syntax=docker/dockerfile:1

FROM golang:1.16.8-alpine3.14
RUN addgroup app && adduser -S -G app app
WORKDIR /app/home
#RUN npm install
COPY . .
RUN go get github.com/gobuffalo/pop/...
EXPOSE 4000
RUN soda migrate

CMD go build -o movies cmd/api/*.go && ./movies


For bug reports, please provide as much relevant info as possible.

Steps to Reproduce the Problem

Please describe in painful detail what you did (so others can play along with you) to get to this point. This includes things like the exact command(s) you used, or the curl command you used, that sort of thing.

  1. spin up a container with go and alpine
  2. install soda
  3. run migration as a RUN

Expected Behavior

What did you what to happen? Tell us a story. We love to read.
that it would use the env vars referred to in the go template and set by the env file

Actual Behavior

In the happiest of happy places what should have happened?

Info

wsl2 Linux soda v5.3.1
Please precise your OS, the Pop version and if you're using Pop through Buffalo.

@sio4
Copy link
Member

sio4 commented Dec 3, 2021

The op reported the issue was resolved. closing.

@sio4 sio4 closed this as completed Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants