Skip to content

Commit

Permalink
Added docker file and instructions to build using actions
Browse files Browse the repository at this point in the history
  • Loading branch information
fbanados committed Sep 3, 2024
1 parent 93c3683 commit 72a7440
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build docker image
on: [ push ]

env:
ACTIONS_PYTHON_VERSION: '3.10'

jobs:
build-docker-image:
runs-on: ubuntu-latest
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_PERSONAL_ACCESS_TOKEN }}
- uses: actions/checkout@v4
- name: Build and push Docker images
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: true
cache-from: |
type=registry,ref=ghcr.io/ualbertaaltlab/wordnet-docker:latest
tags: |
ghcr.io/ualbertaaltlab/wordnet-docker:${{ github.sha }}
ghcr.io/ualbertaaltlab/wordnet-docker:latest
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Based on the process to make speech-db

FROM python:3.10 AS builder
ENV PYTHONUNBUFFERED 1
WORKDIR /app
COPY Pipfile Pipfile.lock ./
RUN pip install pipenv
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy --dev

RUN apt-get update -qq && apt-get -y install curl unzip
RUN mkdir /app/nltk_data
RUN curl https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/packages/corpora/wordnet31.zip -o nltk_data/wordnet31.zip
RUN mkdir -p -v /app/nltk_data/corpora/
RUN unzip nltk_data/wordnet31.zip -d /app/nltk_data/corpora/
RUN mv -v /app/nltk_data/corpora/wordnet31 /app/nltk_data/corpora/wordnet

FROM python:3.10
ARG UID_GID=60005
ARG WSGI_USER=wordnet
RUN groupadd --system --gid ${UID_GID} ${WSGI_USER} \
&& useradd --no-log-init --system --gid ${WSGI_USER} --uid ${UID_GID} ${WSGI_USER} \
&& mkdir /app \
&& mkdir /app/nltk_data \
&& chown ${WSGI_USER}:${WSGI_USER} /app /app/nltk_data

USER ${WSGI_USER}:${WSGI_USER}
WORKDIR /app/

COPY --from=builder --chown=${WSGI_USER}:${WSGI_USER} /app/.venv /app/.venv
COPY --from=builder --chown=${WSGI_USER}:${WSGI_USER} /app/nltk_data /app/nltk_data
COPY --chown=${WSGI_USER}:${WSGI_USER} . .
ENV VIRTUAL_ENV="/app/.venv"
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"

EXPOSE 8000
ENV UWSGI_HTTP=:8000 UWSGI_MASTER=1 UWSGI_HTTP_KEEPALIVE=0 UWSGI_AUTO_CHUNKED=1 UWSGI_WSGI_ENV_BEHAVIOUR=holy
CMD ["uwsgi", "-w", "wordnet.wsgi", "--processes", "2"]

0 comments on commit 72a7440

Please sign in to comment.