aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ChrisJL <[email protected]>2022-09-11 01:13:40 +0100
committerGravatar GitHub <[email protected]>2022-09-11 01:13:40 +0100
commit4f4d877c5fd85b959d8c6c1909362a94ed8750c9 (patch)
tree47b188a823f151ef64a4ef16bedcdf43edd325eb
parentMerge pull request #18 from python-discord/bump-dep (diff)
parentRemove CI env vars (diff)
Merge pull request #24 from python-discord/poetry-1.2.0
-rw-r--r--.github/workflows/lint-build-deploy.yaml50
-rw-r--r--Dockerfile24
2 files changed, 24 insertions, 50 deletions
diff --git a/.github/workflows/lint-build-deploy.yaml b/.github/workflows/lint-build-deploy.yaml
index f28530f..e39a4ac 100644
--- a/.github/workflows/lint-build-deploy.yaml
+++ b/.github/workflows/lint-build-deploy.yaml
@@ -14,54 +14,16 @@ jobs:
lint:
name: Lint
runs-on: ubuntu-latest
- env:
- # Configure pip to cache dependencies and do a user install
- PIP_NO_CACHE_DIR: false
- PIP_USER: 1
-
- # Make sure package manager does not use virtualenv
- POETRY_VIRTUALENVS_CREATE: false
-
- # Specify explicit paths for python dependencies and the pre-commit
- # environment so we know which directories to cache
- POETRY_CACHE_DIR: ${{ github.workspace }}/.cache/py-user-base
- PYTHONUSERBASE: ${{ github.workspace }}/.cache/py-user-base
- PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit-cache
-
steps:
- - name: Add custom PYTHONUSERBASE to PATH
- run: echo '${{ env.PYTHONUSERBASE }}/bin/' >> $GITHUB_PATH
-
- name: Checkout repository
uses: actions/checkout@v2
- - name: Setup python
- id: python
- uses: actions/setup-python@v2
+ - name: Install Python Dependencies
+ uses: HassanAbouelela/actions/setup-python@setup-python_v1.3.1
with:
- python-version: '3.10'
-
- # This step caches our Python dependencies. To make sure we
- # only restore a cache when the dependencies, the python version,
- # the runner operating system, and the dependency location haven't
- # changed, we create a cache key that is a composite of those states.
- #
- # Only when the context is exactly the same, we will restore the cache.
- - name: Python Dependency Caching
- uses: actions/cache@v2
- id: python_cache
- with:
- path: ${{ env.PYTHONUSERBASE }}
- key: "python-0-${{ runner.os }}-${{ env.PYTHONUSERBASE }}-\
- ${{ steps.python.outputs.python-version }}-\
- ${{ hashFiles('./pyproject.toml', './poetry.lock') }}"
-
- # Install our dependencies if we did not restore a dependency cache
- - name: Install dependencies using poetry
- if: steps.python_cache.outputs.cache-hit != 'true'
- run: |
- pip install poetry
- poetry install
+ # Set dev=true to install flake8 extensions, which are dev dependencies
+ dev: true
+ python_version: '3.10'
# Run flake8 and have it format the linting errors in the format of
# the GitHub Workflow command to register error annotations. This
@@ -183,4 +145,4 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: pull-request-payload
- path: pull_request_payload.json \ No newline at end of file
+ path: pull_request_payload.json
diff --git a/Dockerfile b/Dockerfile
index 34c2f76..ebf7881 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,15 +1,26 @@
FROM --platform=linux/amd64 python:3.10-slim
-ENV PIP_NO_CACHE_DIR=false \
- POETRY_VIRTUALENVS_CREATE=false
+# Set pip to have no saved cache
+ENV PIP_NO_CACHE_DIR=1 \
+ PIP_DISABLE_PIP_VERSION_CHECK=on \
+ POETRY_VERSION=1.2.0 \
+ POETRY_HOME="/opt/poetry" \
+ POETRY_VIRTUALENVS_IN_PROJECT=true \
+ POETRY_NO_INTERACTION=1 \
+ INSTALL_DIR="/opt/dependencies" \
+ APP_DIR="/app"
-# Install poetry
-RUN pip install -U poetry
+ENV PATH="$POETRY_HOME/bin:/$INSTALL_DIR/.venv/bin:$PATH"
-# Create the working directory
-WORKDIR /arthur
+RUN apt-get update \
+ && apt-get -y upgrade \
+ && apt-get install --no-install-recommends -y curl \
+ && apt-get clean && rm -rf /var/lib/apt/lists/*
+
+RUN curl -sSL https://install.python-poetry.org | python
# Install project dependencies
+WORKDIR $INSTALL_DIR
COPY pyproject.toml poetry.lock ./
RUN poetry install --no-dev
@@ -20,6 +31,7 @@ ARG git_sha="development"
ENV GIT_SHA=$git_sha
# Copy the source code in last to optimize rebuilding the image
+WORKDIR $APP_DIR
COPY . .
ENTRYPOINT ["python3"]