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

Dockerfile and a wrapper script to mount template and output directories as volumes... #444

Open
masavini opened this issue Sep 12, 2021 · 3 comments
Assignees
Labels
enhancement good first issue Easy things for newbies hacktoberfest-accepted This PR is a candidate to win a T-shirt if done while the Hacktoberfest is live help wanted The issue is valid, but we need community contributions to fix it

Comments

@masavini
Copy link

Hi,
the Dockerfile could look like this:

FROM python:3.9-alpine

ARG USER=copier
ARG GROUP=copier
ARG UID=1000
ARG GID=1000

RUN addgroup -g "${GID}" "${GROUP}" && \
    adduser -h /home/"${USER}" -u "${UID}" -G "${GROUP}" -s /bin/bash -D "${USER}"


RUN set -ex; \
    apk add --no-cache --virtual .build-deps \
        gcc \
        musl-dev; \
    apk add --no-cache \
        bash \
        git \
        py3-virtualenv;

USER "${USER}"

ENV PATH=/home/${USER}/.local/bin:$PATH


RUN set -ex; \
    python3 -m pip install --user pipx; \
    pipx install copier; \
    pipx install invoke; \
    pipx install pre-commit; \
    pipx ensurepath;


USER root
RUN set -ex; \
    apk del .build-deps;

USER "${USER}"

ENTRYPOINT ["copier"]

I already built it and performed a few tests, it works pretty good.

It would be also nice to have a wrapper script to parse arguments and automatically mount template and output directories as volumes...

What do you think about?

@yajo
Copy link
Member

yajo commented Sep 13, 2021

Seems good to me, but I'm not eager to work on this. However if you want to contribute it, I will review it. Regarding the Dockerfile itself, before somebody opens the PR I'll ask you to change it:

  • According to https://pythonspeed.com/articles/alpine-docker-python/ alpine isn't the best choice. Use python:3.9-slim instead.
  • Also I wouldn't care about users and uids/gids. Whoever cares, can just docker run --user 1000:1000 copier
  • The PR opened must apply https://github.com/Tecnativa/image-template to this repo. It provides lots of good stuff out of the box, like multiarch builds, auto-tagged builds, :edge, :latest... etc.
  • Images should be pushed to ghcr.io, not docker hub (to avoid boring setup).
  • Docs will have to be updated also.

@yajo yajo added good first issue Easy things for newbies hacktoberfest-accepted This PR is a candidate to win a T-shirt if done while the Hacktoberfest is live help wanted The issue is valid, but we need community contributions to fix it labels Sep 13, 2021
@mbwhite
Copy link

mbwhite commented Apr 8, 2022

I was just thinking of doing something similar, but specifically to run with the alpha (that I'm assuming is the master branch?)

On the image-template is the process to clone this (copier) repo, create a branch.. then apply the template?

@yajo
Copy link
Member

yajo commented Apr 10, 2022

Yes, basically.

BTW since my last comment lots of things happened. I'd probably prefer to end using a nix-based image, once #585 is fixed.

Of course that can land later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement good first issue Easy things for newbies hacktoberfest-accepted This PR is a candidate to win a T-shirt if done while the Hacktoberfest is live help wanted The issue is valid, but we need community contributions to fix it
Projects
None yet
Development

No branches or pull requests

3 participants