Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker cleanup #41

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.eggs
*.egg-info

.idea

__pycache__

venv/

.github/
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: publish

on:
push:
branches: [ master ]
tags: ['**']

jobs:
build:
name: Build
runs-on: ubuntu-20.04
steps:
- name: get git tag
id: git_info
if: startsWith(github.ref, 'refs/tags/')
run: echo "::set-output name=tag::${GITHUB_REF##*/}"
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
with:
platforms: amd64,arm64,ppc64le
- uses: docker/setup-buildx-action@v1
id: buildx
- name: docker buildx build
env:
git_tag: ${{ steps.git_info.outputs.tag }}
run: |
dock_image="${GITHUB_REPOSITORY,,}" # to lower case
tag="${git_tag:-latest}" # if build triggered by tag, use tag name
docker buildx build -t $dock_image:$tag --platform ${{ steps.buildx.outputs.platforms }} --progress plain .
# TODO docker login
145 changes: 144 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,144 @@
pfurl/__pycache__/
# Created by .ignore support plugin (hsz.mobi)
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# IDEs
.idea/
.vscode/
59 changes: 8 additions & 51 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,53 +1,10 @@
#
# Dockerfile for pfurl repository.
#
# Build with
#
# docker build -t <name> .
#
# For example if building a local version, you could do:
#
# docker build -t local/pfurl .
#
# In the case of a proxy (located at say 10.41.13.4:3128), do:
#
# export PROXY="http://10.41.13.4:3128"
# docker build --build-arg http_proxy=${PROXY} --build-arg UID=$UID -t local/pfurl .
#
# To run an interactive shell inside this container, do:
#
# docker run -ti --entrypoint /bin/bash local/pfurl
#
# To pass an env var HOST_IP to container, do:
#
# docker run -ti -e HOST_IP=$(ip route | grep -v docker | awk '{if(NF==11) print $9}') --entrypoint /bin/bash local/pfurl
#
# debian is preferred over alpine for installing pycurl seamlessly
FROM python:3.9.1-buster
LABEL version="2.3.1" maintainer="FNNDSC <[email protected]>"

FROM fnndsc/ubuntu-python3:latest
MAINTAINER fnndsc "[email protected]"
WORKDIR /usr/local/src
COPY . .
RUN pip install -r requirements.txt && pip install .

# Pass a UID on build command line (see above) to set internal UID
ARG UID=1001
ENV UID=$UID

COPY . /tmp/pfurl
COPY ./docker-entrypoint.py /dock/docker-entrypoint.py

RUN apt-get update \
&& apt-get install sudo \
&& useradd -u $UID -ms /bin/bash localuser \
&& addgroup localuser sudo \
&& echo "localuser:localuser" | chpasswd \
&& adduser localuser sudo \
&& apt-get install -y libssl-dev libcurl4-openssl-dev bsdmainutils vim net-tools inetutils-ping \
&& pip install --upgrade pip \
&& pip install /tmp/pfurl && rm -fr /tmp/pfurl

RUN chmod 777 /dock \
&& chmod 777 /dock/docker-entrypoint.py \
&& echo "localuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

ENTRYPOINT ["/dock/docker-entrypoint.py"]

# Start as user $UID
USER $UID
ENTRYPOINT ["pfurl"]
CMD ["--synopsis"]
9 changes: 3 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
##################
pfurl - v2.3.0.1
##################
##############
pfurl - v2.3.1
##############

.. image:: https://badge.fury.io/py/pfurl.svg
:target: https://badge.fury.io/py/pfurl
Expand Down Expand Up @@ -201,6 +201,3 @@ Say 'hello' to a ``pfcon`` service listening on the localhost at port 5005:
}' --quiet --jsonpprintindent 4

and print response "prettily" using an indent of 4.



13 changes: 7 additions & 6 deletions bin/pfurl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env python3
#!/usr/bin/env python
#
# (c) 2017-2020 Fetal-Neonatal Neuroimaging & Developmental Science Center
# (c) 2017-2021 Fetal-Neonatal Neuroimaging & Developmental Science Center
# Boston Children's Hospital
#
# http://childrenshospital.org/FNNDSC/
# [email protected]
#

import sys, os
sys.path.insert(1, os.path.join(os.path.dirname(__file__), '..'))
import sys
import os

import socket
import json
Expand All @@ -19,12 +19,13 @@ import pudb
from argparse import RawTextHelpFormatter
from argparse import ArgumentParser
from pfmisc._colors import Colors
from pfmisc import local_ip_address

str_defIP = [l for l in ([ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")][:1], [[(s.connect(('8.8.8.8', 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1]]) if l][0][0]
str_defIP = local_ip_address()
str_defPort = '5055'

str_name = 'pfurl'
str_version = "2.3.0.1"
str_version = "2.3.1"
str_desc = Colors.CYAN + """

__ _
Expand Down
Loading