Skip to content

Instantly share code, notes, and snippets.

@dereckmezquita
Created March 28, 2024 17:49
Show Gist options
  • Save dereckmezquita/8fd80addf1c6d6d1a15ea20806c17507 to your computer and use it in GitHub Desktop.
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.
#!/usr/bin/env bash
docker build --build-arg DETECTED_BUILD='PROD' -t dereckmezquita/hello-world:latest .
docker run dereckmezquita/hello-world:latest
#> YEET
FROM ubuntu:20.04
WORKDIR /app
ARG DETECTED_BUILD
ENV BUILD=$DETECTED_BUILD
COPY . .
ENTRYPOINT [ "/bin/bash", "yeet.sh" ]
#!/usr/bin/env bash
echo $BUILD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment