sjmayotte / route53-dynamic-dns

Update AWS Route53 hosted zone with current public IP address. Alternative to Dynamic DNS services such as Dyn, No-IP, etc
https://sjmayotte.dev/route53-dynamic-dns/
MIT License
41 stars 22 forks source link

Unable to load environment variables from .env file #10

Closed peavers closed 3 years ago

peavers commented 3 years ago

Everything was cool until I pulled the latest update. Now when attempting to start the container I just get:

[2021-02-18T15:53:05.144] [INFO] default - Unable to load environment variables from .env file.  Process is likely running in a container.  Make sure you pass environment variables when starting container.
[2021-02-18T15:53:05.145] [ERROR] default - Error: ENOENT: no such file or directory, open '/usr/src/app/.env'
    at Object.openSync (fs.js:440:3)
    at Object.readFileSync (fs.js:342:35)
    at Object.config (/usr/src/app/node_modules/dotenv/lib/main.js:96:29)
    at Object.<anonymous> (/usr/src/app/server.js:59:29)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
    at internal/main/run_main_module.js:17:11 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/usr/src/app/.env'
}

I'm starting via a docker-compose script

  route53-dynamic-dns:
    container_name: route53-dynamic-dns
    image: sjmayotte/route53-dynamic-dns:latest
    restart: unless-stopped
    environment:
      - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
      - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
      - AWS_REGION=${AWS_REGION}
      - ROUTE53_HOSTED_ZONE_ID=${ROUTE53_HOSTED_ZONE_ID}
      - ROUTE53_DOMAIN=${DOMAIN}
      - ROUTE53_TYPE=A
      - ROUTE53_TTL=60
      - SEND_EMAIL_SES=false
      - SES_TO_ADDRESS=${SES_TO_ADDRESS}
      - SES_FROM_ADDRESS=${SES_FROM_ADDRESS}
      - UPDATE_FREQUENCY=60000
      - LOG_TO_STDOUT=true
    logging:
      options:
        max-size: "2m"
        max-file: "5"
    labels:
      - traefik.enable=false
sjmayotte commented 3 years ago

I should be able to review the issue in greater detail this weekend.

@peavers - for now, you can use v1.1 tag, which is the last official release of code. That should work without issue.

docker pull sjmayotte/route53-dynamic-dns:v1.1

Will provide more updates after I have time to review

sjmayotte commented 3 years ago

@peavers - issue should be fixed on latest image. Let me know if you have any further issues.

I'm going to be changing how we do image tags and will make sure latest always points to the latest stable version and use another tag for dev builds. Should prevent this type of issue in the future. Change will be implemented with next release in the next week or so.

peavers commented 3 years ago

The same issue even after pulling the latest, but yeah rolled back to 1.1 and everything is good.

sjmayotte commented 3 years ago

@peavers - Just pushed a new release with tags v1.2.0 and latest. The error case you encountered should be fixed. Let me know if you have any issues.

sjmayotte commented 3 years ago

Closing issue. Please reopen if it persists.

jevy commented 3 years ago

Howdy! Just had a similar issue:

$ docker run -d -t -i --rm \
    --name route53-dynamic-dns \
    -e AWS_ACCESS_KEY_ID=<ID> \
    -e AWS_SECRET_ACCESS_KEY=<secret> \
    -e AWS_REGION=us-east-1 \
    -e ROUTE53_HOSTED_ZONE_ID=<ID> \
    -e ROUTE53_DOMAIN=<domain> \
    -e ROUTE53_TYPE=A \
    -e ROUTE53_TTL=60 \
    -e LOG_TO_STDOUT=true \
    sjmayotte/route53-dynamic-dns:latest

Then checking the logs

docker logs route53-dynamic-dns

> route53dynamicdns@1.2.0 start /usr/src/app
> node startup.js

Log4js initialized with level INFO

Logging is configured to STDOUT
[2021-08-27T16:20:47.201] [INFO] default - Unable to load environment variables from .env file.  Process is likely running in a container.  Make sure you pass environment variables when starting container.
jevy commented 3 years ago

Aww drat. If I had waited a minute I would see that it does in fact work. It was just the initial error message that threw me off. This is great! Thank you.