this post was submitted on 06 Sep 2023
14 points (88.9% liked)

Selfhosted

40329 readers
492 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS
 

Hope this is a proper sub for asking this.

disclaimer : Consider me a programming novice, with HTML and limited PHP/CSS experience.

Ive been messing with docker compose, and i'm loving it. Ive also written a small script that i want to dockerize, but i want to use the environment list. What is a proper code for getting the ENV data in your script?

Ive been duckduckgo-ing (doesnt sound like the old days, does it) and i cant figure it out.

top 12 comments
sorted by: hot top controversial new old
[–] xanu@lemmy.world 14 points 1 year ago

https://docs.docker.com/compose/environment-variables/set-environment-variables/

I really like using .env files, but you can hard code env vars in the compose file itself if you want.

[–] thomasloven@lemmy.world 5 points 1 year ago (1 children)

Depends on the language the script is written in. If it’s bash/sh then it’s usually just $VARIABLE

[–] cmhe@lemmy.world 2 points 1 year ago

Environment variables isn't a concept of just docker, but general native app programming. So look into the docs of your language.

[–] webuge@lemmy.dbzer0.com 3 points 1 year ago (1 children)

In my opinion you would want to create a Dockerfile to generate a Docker Image with your script and the ENVs in it. Remember though this script will run inside the docker container and the host will not see any modification. Could you explain in more details what this script would do?

[–] TvanBuuren@feddit.nl 2 points 1 year ago (1 children)

right now its a javascript countdown till christmas.

Id like to pass the target year through a variable though.

[–] DontAskAboutUpdog@lemmy.world 2 points 1 year ago (1 children)

Not trying to be an AH but that is not suitable for an ENV. Instead pass the year through the URL

[–] TvanBuuren@feddit.nl 1 points 1 year ago

I know it SHOULD be done that way, but i want the URL to be clean.

[–] TrustingZebra@lemmy.one 3 points 1 year ago (1 children)

You need to learn how to write a Dockerfile (plenty of guides online). Not that a Dockerfile is different from a compose.yaml file (in development I use both).

[–] TvanBuuren@feddit.nl 1 points 1 year ago (1 children)

The whole docker thing is rather new to me, thanks for the hints.

[–] TrustingZebra@lemmy.one 2 points 1 year ago

No problem! Let me know if you have questions. Docker was new to me a few years ago, now I work with it professionally.

[–] conrad82@lemmy.world 2 points 1 year ago (1 children)

Not a direct answer to your question, but I learned a bit by searching github for Dockerfile and docker-compose.yml

[–] TvanBuuren@feddit.nl 1 points 1 year ago

Thanks for the pointer.