Skip to content

Commit

Permalink
Merge pull request #203 from jstockwin/misc-fixes
Browse files Browse the repository at this point in the history
Misc fixes
  • Loading branch information
jstockwin authored May 14, 2021
2 parents 08c9a0b + 152e7de commit 8c522f9
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 112 deletions.
23 changes: 21 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,31 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build the tests docker container
uses: docker/build-push-action@v2.4.0
with:
context: .
file: dockerfiles/Dockerfile_tests
tags: jstockwin/py-pdf-parser-test:test
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
load: true
# This ugly bit is necessary if you don't want your cache to grow forever
# till it hits GitHub's limit of 5GB.
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Run linting
run: docker run --rm jstockwin/py-pdf-parser-test:test .github/scripts/lint.sh
- name: Run test
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,13 @@ jobs:
- name: Get the tag
id: tagName
run: echo ::set-output name=tag::${GITHUB_REF/refs\/tags\//}
- name: Publish to docker hub
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: jstockwin/py-pdf-parser
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
dockerfile: dockerfiles/Dockerfile
tags: ${{ steps.tagName.outputs.tag }}
- name: Install build packages
run: pip3 install twine==3.1.1 wheel==0.34.2
- name: Build package
run: python3 setup.py sdist bdist_wheel
- name: Check built package
run: twine check dist/*
- name: Package package to PyPI
- name: Publish package to PyPI
run: twine upload dist/*
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed
- Removed all but the tests dockerfile for simplicity. Use Docker BuildKit. We will no longer be pushing images to DockerHub on release. ([#203](https://github.com/jstockwin/py-pdf-parser/pull/203))

## [0.8.0] - 2021-05-12
### Changed
- Various dependency updates
- Updated CI to avoid login issue ([#182](https://github.com/jstockwin/py-pdf-parser/pull/182))
- Updated CI to avoid login issue ([#182](https://github.com/jstockwin/py-pdf-parser/pull/182))

## [0.7.0] - 2021-01-15
### Changed
Expand Down
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# syntax = docker/dockerfile:1.2
FROM phusion/baseimage:focal-1.0.0

RUN adduser --disabled-password --gecos "" app_user

RUN apt-get update && \
apt-get -y install software-properties-common \
python3-dev \
python3-pip \
python3-virtualenv \
libmagickwand-dev \
xvfb && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ENV VIRTUAL_ENV_DIR /.venv
RUN python3 -m virtualenv --python=python3.8 $VIRTUAL_ENV_DIR
# Set the virtual environment as the main Python directory
ENV PATH $VIRTUAL_ENV_DIR/bin:$PATH

RUN --mount=type=cache,target=/root/.cache/pip pip3 install --upgrade pip

# Create src dir
ENV PROJECT_DIR /py-pdf-parser
WORKDIR $PROJECT_DIR

# Add imagemagick policy
ADD ./imagemagick_policy.xml /etc/ImageMagick-6/policy.xml

# Install requirements
ADD ./setup.py $PROJECT_DIR/setup.py
ADD ./README.md $PROJECT_DIR/README.md
RUN --mount=type=cache,target=/root/.cache/pip pip3 install -e $PROJECT_DIR[dev]
RUN --mount=type=cache,target=/root/.cache/pip pip3 install -e $PROJECT_DIR[test]
RUN chown -R app_user:app_user $VIRTUAL_ENV_DIR

# Copy code, chown and switch user
ADD ./ $PROJECT_DIR
RUN chown -R app_user:app_user $PROJECT_DIR
USER app_user
6 changes: 0 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
shell:
build: .
dockerfile: dockerfiles/Dockerfile_dev
volumes:
- .:/py-pdf-parser
- /tmp/.X11-unix:/tmp/.X11-unix:rw
Expand All @@ -11,7 +10,6 @@ shell:

lint:
build: .
dockerfile: dockerfiles/Dockerfile_tests
volumes:
- .:/py-pdf-parser
# pytype pyi-error disabled due to https://github.com/google/pytype/issues/355
Expand All @@ -21,14 +19,12 @@ lint:

lint-fix:
build: .
dockerfile: dockerfiles/Dockerfile_tests
volumes:
- .:/py-pdf-parser
command: bash -c "black ."

tests:
build: .
dockerfile: dockerfiles/Dockerfile_tests
volumes:
- .:/py-pdf-parser
- /tmp/.X11-unix:/tmp/.X11-unix:rw
Expand All @@ -39,7 +35,6 @@ tests:
# Run docs to re-build the docs once.
docs:
build: .
dockerfile: dockerfiles/Dockerfile_tests
volumes:
- .:/py-pdf-parser
command: make --directory docs html
Expand All @@ -49,7 +44,6 @@ docs:
# Use "up" to host the docs on port 8000, watching for changes.
docs-autobuild:
build: .
dockerfile: dockerfiles/Dockerfile_tests
volumes:
- .:/py-pdf-parser
ports:
Expand Down
28 changes: 0 additions & 28 deletions dockerfiles/Dockerfile

This file was deleted.

31 changes: 0 additions & 31 deletions dockerfiles/Dockerfile_dev

This file was deleted.

35 changes: 0 additions & 35 deletions dockerfiles/Dockerfile_tests

This file was deleted.

0 comments on commit 8c522f9

Please sign in to comment.