Skip to content

Commit

Permalink
Merge pull request #1 from TravisWheelerLab/dockerize
Browse files Browse the repository at this point in the history
Add Docker configuration
  • Loading branch information
glesica authored Feb 1, 2022
2 parents 4b978b9 + 842c8dc commit 709c0b7
Show file tree
Hide file tree
Showing 9 changed files with 889 additions and 1 deletion.
47 changes: 47 additions & 0 deletions .github/workflows/container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Create and publish a Docker image

on:
workflow_dispatch:
release:
types: ['published']

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

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

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM python:3.9-slim-bullseye AS build

WORKDIR /opt
COPY Pipfile ./
COPY Pipfile.lock ./
RUN pip install pipenv \
&& pipenv sync \
&& pipenv run pip freeze > requirements.txt

FROM python:3.9-slim-bullseye

RUN mkdir /opt/shopty
WORKDIR /opt/shopty

COPY --from=build /opt/requirements.txt ./
RUN pip install -r requirements.txt
COPY shopty/ shopty/

VOLUME /data
WORKDIR /data

ENV PYTHONPATH=/opt/shopty
ENTRYPOINT ["python3", "-m", "shopty"]
14 changes: 14 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
pytorch-lightning = ">=1.5.0"
pyyaml = ">=6.0.0"
numpy = ">=1.0.0"

[dev-packages]

[requires]
python_version = "3.9"
786 changes: 786 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion shopty/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
shopty is a tool for tuning hyperparameters on your computer or slurm-managed clusters.
"""
__version__ = "0.0.3"
from ._version import __version__

from .experiments import *
from .supervisors import *
Expand Down
4 changes: 4 additions & 0 deletions shopty/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .cli import main

if __name__ == "__main__":
main()
4 changes: 4 additions & 0 deletions shopty/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__version__ = "0.0.3"

if __name__ == "__main__":
print(__version__)
5 changes: 5 additions & 0 deletions tool/build-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh

set -e

docker build -t shopty .
5 changes: 5 additions & 0 deletions tool/run-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh

set -e

docker run -v $PWD:/data -u "$(id -u):$(id -g)" shopty "$@"

0 comments on commit 709c0b7

Please sign in to comment.