Created
March 28, 2024 17:49
-
-
Save dereckmezquita/8fd80addf1c6d6d1a15ea20806c17507 to your computer and use it in GitHub Desktop.
Pass env vars to docker image on build, can be used to pass vars during github actions for building a prod vs dev image.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
docker build --build-arg DETECTED_BUILD='PROD' -t dereckmezquita/hello-world:latest . | |
docker run dereckmezquita/hello-world:latest | |
#> YEET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:20.04 | |
WORKDIR /app | |
ARG DETECTED_BUILD | |
ENV BUILD=$DETECTED_BUILD | |
COPY . . | |
ENTRYPOINT [ "/bin/bash", "yeet.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo $BUILD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment