What I'm trying to accomplish is this: I want to cache the current users ~/.aws directory inside a container so that I can use them during the build of another container.
I have the following docker-compose.yml:
version: "3.7"
services:
worker:
depends_on:
- aws
aws:
build:
context: ~/.aws
dockerfile: ./ctx.dockerfile
args:
- workdir=/root/.aws
These are the contents of ctx.dockerfile:
FROM alpine:3.9
ARG workdir
WORKDIR ${workdir}
COPY . .
And in my worker service Dockerfile I have the following:
...
COPY --from=aws_ctx:local /root/.aws /root/.aws
...
The Problem
docker compose isn't treating the dockerfile path in the aws service as relative to the docker-compose.yml, it is instead assuming it is relative to the context path. Is there anyway I can have docker-compose load the ctx.dockerfile from same directory as docker-compose.yml AND set the context the way that I am?
I'm up for changing my approach to the problem, but I have a few contstraints:
- any solution must be workable on Windows, OSX, and Linux
- any solution must only require docker and/or docker-compose, I can't run a shell script beforehand