Docker, where to put COPY .env in Dockerfile

Im going to production, with fly.io.

I have a .env file with my secrets, however, where do I have to put COPY .env .
I tried putting it at the top of the file, and the bottom and also below the FROM ${RUNNER_IMAGE} because its always saying that it cant read the .env file …
Here is my whole Dockerfile 659uYQJcuw | SourceBin

Edit: its building locally, tho errors on fly.io fly deploy

The default Dockerfile that fly launch generates for me is:

... 

ARG ELIXIR_VERSION=1.13.4
ARG OTP_VERSION=24.3.4
ARG DEBIAN_VERSION=bullseye-20210902-slim

ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"

FROM ${BUILDER_IMAGE} as builder

# install build dependencies
RUN apt-get update -y && apt-get install -y build-essential git \
    && apt-get clean && rm -f /var/lib/apt/lists/*_*

...

Try it this way

Can you send your dockerfile in a sourcebin? for me its only showing 15% or less

Your secrets are not supposed to be in your Docker image. Have a look at fly.io docs: Secrets and Fly Apps · Fly Docs

2 Likes