Skip to content

Commit

Permalink
Merge pull request #55 from PeARSearch/add-dockerfile
Browse files Browse the repository at this point in the history
Add dockerfile
  • Loading branch information
minimalparts authored Jul 1, 2024
2 parents c7b27f8 + d498210 commit 8355afd
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git/
.github/
.idea/

.gitignore
34 changes: 34 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Docker Image CI

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: deployment/Dockerfile
push: true
tags: pearsproject/pears-federated:latest

- name: Image digest
run: echo ${{ steps.build.outputs.digest }}
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.DEFAULT_GOAL: help
SHELL := /bin/bash

PROJECTNAME := "pears-federated"

.PHONY: help
all: help
help: Makefile
@echo
@echo " Choose a command to run in "$(PROJECTNAME)":"
@echo
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@echo note: call scripts from /scripts

check-%: # detection of required software.
@which ${*} > /dev/null || (echo '*** Please install `${*}` ***' && exit 1)

## build: Build the container image
build: check-docker
@docker buildx build --no-cache --pull -f deployment/Dockerfile -t ${PROJECTNAME}:local-build .
4 changes: 2 additions & 2 deletions app/indexer/posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
pod_dir = getenv("PODS_DIR", join(dir_path, 'pods'))

def load_posix(contributor, lang, theme):
posix_path = join(dir_path, 'pods', contributor, lang)
posix_path = join(pod_dir, contributor, lang)
pod_name = theme+'.u.'+contributor
posix = joblib.load(join(posix_path,pod_name+'.pos'))
return posix

def dump_posix(posindex, contributor, lang, theme):
posix_path = join(dir_path, 'pods', contributor, lang)
posix_path = join(pod_dir, contributor, lang)
pod_name = theme+'.u.'+contributor
joblib.dump(posindex, join(posix_path,pod_name+'.pos'))

Expand Down
2 changes: 1 addition & 1 deletion app/orchard/mk_urls_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
def get_url_list_for_users(theme):
urls = []
url_theme = theme.replace(' ', '_')
hfile = join(pods_dir, url_theme + ".pears.txt")
hfile = join(pod_dir, url_theme + ".pears.txt")
f_out = open(hfile,'w', encoding='utf-8')
for url in Urls.query.filter(Urls.pod.contains(theme+'.u.')).all():
if not url.pod.startswith(theme+'.u.'):
Expand Down
26 changes: 26 additions & 0 deletions deployment/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM python:3.9-slim

WORKDIR /app

COPY requirements.txt /tmp/
RUN pip install --requirement /tmp/requirements.txt

# Additionally, install Gunicorn
RUN pip install gunicorn

# Make port 8000 available to the world outside this container
EXPOSE 8000

ENV SQLALCHEMY_DATABASE_URI="sqlite:////var/lib/pears/data/app.db"
ENV LOGO_PATH="/var/lib/pears/data"
ENV PODS_DIR="/var/lib/pears/data/pods"
ENV SUGGESTIONS_DIR="/var/lib/pears/data/userdata"

RUN mkdir -p /var/lib/pears/data/pod /var/lib/pears/data/userdata

COPY . /app

RUN chmod +x /app/deployment/entrypoint.sh

# Set the entrypoint script to be executed
ENTRYPOINT ["/app/deployment/entrypoint.sh"]
6 changes: 6 additions & 0 deletions deployment/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# entrypoint.sh

flask db migrate

gunicorn -b 0.0.0.0:8000 -w 3 -t 120 app:app

0 comments on commit 8355afd

Please sign in to comment.