Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prebuilt docker image for faster runs #59

Open
nitrocode opened this issue Sep 16, 2019 · 3 comments
Open

Prebuilt docker image for faster runs #59

nitrocode opened this issue Sep 16, 2019 · 3 comments

Comments

@nitrocode
Copy link
Contributor

nitrocode commented Sep 16, 2019

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
Copy link
Owner

mszep commented Sep 20, 2019

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
Copy link
Contributor Author

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
Copy link
Owner

mszep commented Sep 22, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants