-
-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* FIX #49: Docker setup and instructions * ADD: Test docker * ADD: Conditional testing on Docker
- Loading branch information
Showing
3 changed files
with
56 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,65 @@ | ||
name: docker | ||
name: Docker Build and Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- "master" | ||
pull_request: | ||
branches: | ||
- "master" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Build and push | ||
|
||
# Build and push: If this is a push to master, tag as 'latest' | ||
- name: Build and push (production) | ||
if: github.ref == 'refs/heads/master' | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/sort-google-scholar:latest | ||
|
||
# Build and push: If this is a pull request, push to a 'test' tag | ||
- name: Build and push (test) | ||
if: github.event_name == 'pull_request' | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/sort-google-scholar:test | ||
|
||
# Pull and test the production image (only for master branch pushes) | ||
- name: Pull the image from Docker Hub (production) | ||
if: github.ref == 'refs/heads/master' | ||
run: docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/sort-google-scholar:latest | ||
|
||
- name: Test Docker Image (production) | ||
if: github.ref == 'refs/heads/master' | ||
run: docker run --rm ${{ secrets.DOCKER_HUB_USERNAME }}/sort-google-scholar:latest "deep learning" --nresults 20 | ||
|
||
# Pull and test the test image (only for PRs) | ||
- name: Pull the image from Docker Hub (test) | ||
if: github.event_name == 'pull_request' | ||
run: docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/sort-google-scholar:test | ||
|
||
- name: Test Docker Image (test) | ||
if: github.event_name == 'pull_request' | ||
run: docker run --rm ${{ secrets.DOCKER_HUB_USERNAME }}/sort-google-scholar:test "deep learning" --nresults 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
FROM python:3.10-slim | ||
# Use a lightweight Python base image | ||
FROM python:3.11-slim | ||
|
||
WORKDIR /usr/src/app | ||
# Set environment variables to ensure Python doesn't buffer outputs | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
COPY requirements.txt ./ | ||
RUN python -m pip install --upgrade pip \ | ||
&& pip install --no-cache-dir -r requirements.txt | ||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
COPY . . | ||
# Install sortgs from pip | ||
RUN pip install sortgs | ||
|
||
CMD [ './sortgs.py' ] | ||
# Set the entry point to use sortgs as the default command | ||
ENTRYPOINT ["sortgs"] | ||
|
||
# By default, run sortgs with an example search keyword | ||
CMD ["--help"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters