diff --git a/Dockerfile b/Dockerfile index b94a11f..ce3e075 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,4 +51,6 @@ RUN export PATH="/root/.local/bin:$PATH" \ && poetry lock \ && poetry export -f requirements.txt --without-hashes --output requirements.txt +CMD [ "/bin/bash", "-c", "cp /code/* /poetry -r && chown ${USER}:$USER -R /poetry" ] + diff --git a/README.md b/README.md index 5fef917..49acd02 100644 --- a/README.md +++ b/README.md @@ -2,18 +2,24 @@ Used for poetry packages management with docker -required `docker` and `docker-compose` +required `docker` and optionally `docker-compose` -## Poetry lock for any version +## Generate poetry lock for any version -- copy `pyproject.toml` file to poetry dir -- set `python` version the same as in `pyproject.toml` and set `poetry` versions in Dockerfile +- copy `pyproject.toml` file to `poetry` dir +- In Dockerfile set `python` version the same as in `pyproject.toml` and `poetry` version which will be used -run +### Run from docker: + +```bash +docker build --build-arg USER=$USER -t poetry-python . && docker run --rm -u $USER -v $PWD/poetry:/poetry poetry-python +``` + +### Or from docker-compose: ```bash docker-compose up --build ``` -script will generate `poetry.lock` and `requirements.txt` files \ No newline at end of file +script will generate `poetry.lock` and `requirements.txt` files in `poetry` directory \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 7a5613b..75b5599 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,16 +4,11 @@ services: python: image: "poetry-python:latest" container_name: 'poetry-python' + user: ${USER} build: context: . dockerfile: Dockerfile args: - USER=${USER} volumes: - - ./poetry/:/poetry/ - command: > - bash -c " - cp /code/* /poetry -r - && sleep 2 - && chown ${USER}:$USER -R /poetry - " \ No newline at end of file + - ./poetry/:/poetry/ \ No newline at end of file