|
| 1 | +# Use Python 3.8 slim image as the base |
1 | 2 | FROM python:3.8-slim as py3.8 |
| 3 | + |
| 4 | +# Set the working directory |
2 | 5 | WORKDIR /app |
3 | 6 |
|
| 7 | +# Install necessary system packages |
4 | 8 | RUN apt-get update && apt-get install -y \ |
5 | | - build-essential \ |
6 | | - make |
| 9 | + gcc \ |
| 10 | + make \ |
| 11 | + && apt-get clean \ |
| 12 | + && rm -rf /var/lib/apt/lists/* |
7 | 13 |
|
8 | | -# Copy application files |
| 14 | +# Copy application files into the container |
9 | 15 | COPY newtype/ ./newtype/ |
10 | 16 | COPY tests/ ./tests/ |
11 | 17 | COPY build.py ./ |
12 | 18 | COPY Makefile ./ |
13 | 19 | COPY README.md ./ |
14 | 20 | COPY pyproject.toml ./ |
15 | 21 |
|
| 22 | +# Create a virtual environment and install test dependencies |
| 23 | +RUN python -m venv .venv && \ |
| 24 | + . .venv/bin/activate && \ |
| 25 | + make install-test && \ |
| 26 | + deactivate |
| 27 | + |
| 28 | +FROM python:3.8-slim as py3.8 |
| 29 | + |
| 30 | +# Change to the client directory |
| 31 | +WORKDIR /client |
| 32 | + |
| 33 | +# Install necessary system packages |
| 34 | +RUN apt-get update && apt-get install -y \ |
| 35 | + gcc \ |
| 36 | + make \ |
| 37 | + && apt-get clean \ |
| 38 | + && rm -rf /var/lib/apt/lists/* |
| 39 | + |
| 40 | +# Copy the distribution files and example script |
| 41 | +COPY dist/ ./dist/ |
| 42 | +COPY tests/ ./ |
| 43 | +COPY Makefile ./ |
| 44 | +COPY examples/demo.py ./ |
| 45 | + |
| 46 | +# Install the package from the distribution |
16 | 47 | RUN python -m venv .venv && \ |
17 | 48 | . .venv/bin/activate && \ |
18 | | - make install-test |
| 49 | + python -m pip install dist/*.tar.gz && \ |
| 50 | + python -c "from newtype import NewType" && \ |
| 51 | + python -m demo && \ |
| 52 | + python -m pip install pytest && \ |
| 53 | + python -m pip install pandas && \ |
| 54 | + make test && \ |
| 55 | + deactivate |
19 | 56 |
|
| 57 | +# Set the default command to execute when the container starts |
20 | 58 | CMD ["echo", "all tests done"] |
0 commit comments