mszep / pandoc_resume

The Markdown Resume
http://mszep.github.io/pandoc_resume/
MIT License
1.62k stars 756 forks source link

Prebuilt docker image for faster runs #59

Open nitrocode opened 4 years ago

nitrocode commented 4 years ago

Noticed that the docker image has to build from scratch each time. It would be nice to have a Dockerfile that uses a prebuilt image of resume.dockerfile so it just quickly works.

Built and pushed this image using these instructions.

docker login
docker build . -f .docker/resume.dockerfile
docker tag resume-make:latest drianthoderyme/pandoc-resume:latest
docker push drianthoderyme/pandoc-resume:latest

https://hub.docker.com/r/drianthoderyme/pandoc-resume

then you can add a Dockerfile with this

FROM drianthoderyme/pandoc-resume

# prepare a user which runs everything locally! - required in child images!
RUN useradd --user-group --create-home --shell /bin/false app

ENV HOME=/home/app
WORKDIR $HOME

ENV APP_NAME=resume

# before switching to user we need to set permission properly
# copy all files, except the ignored files from .dockerignore
COPY . $HOME/$APP_NAME/
COPY ./Makefile $HOME/$APP_NAME/
RUN chown -R app:app $HOME/*

USER app
WORKDIR $HOME/$APP_NAME

RUN make

and then update the docker-compose.yml to use the new Dockerfile

      dockerfile: ./.docker/Dockerfile

Finally, run docker-compose up -d to build the files correctly.

I'd put in a PR but I think the Docker image should be from the repo owner so it's more official but feel free to use mine.

mszep commented 4 years ago

Forgive me, I'm not a docker expert -- when you say the image has to be built from scratch each time, do you mean each time the resume is changed?

Also, when you build the image locally, how long does it take? Is it a few seconds, or more than a minute?

nitrocode commented 4 years ago

The docker image requires context to be installed and that takes about 10 minutes. I was trying to run the docker image within a gitlab runner which caused each run to take around 10 minutes. By building the container with context preinstalled and pushing it up to dockerhub and then reusing that image using a new Dockerfile, I was able to save 9 minutes on each run.

Locally running this, you'd only have to build the container once before you could keep reusing it. With a prebuilt container with context inside, no one would have to wait 10 minutes to run the app.

mszep commented 4 years ago

OK, thanks for the context. I wonder if we could have a single docker file the builds either from the base image, or from scratch, depending on a parameter.

I'll look into it, and if it's not possible I'll implement it your way.