Skip to content

Commit

Permalink
refactor docker files. #101
Browse files Browse the repository at this point in the history
  • Loading branch information
krikit committed Mar 31, 2021
1 parent 778273a commit 5d1c727
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 181 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__pycache__
build/
41 changes: 41 additions & 0 deletions docker/Dockerfile.centos-7.9.2009
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM centos:7.9.2009 AS base

# install base packages
RUN yum -y install glibc-langpack-en glibc-langpack-ko python3 python3-pip
RUN pip3 install --upgrade pip wheel

# branch to build khaiii
FROM base AS build
RUN yum -y groupinstall "Development Tools" && \
yum -y install centos-release-scl && \
yum -y install devtoolset-7
RUN pip3 install cmake
COPY . /khaiii
WORKDIR /khaiii/build
RUN source /opt/rh/devtoolset-7/enable && \
cmake .. && \
make -j && \
make resource && \
test/khaiii && \
make install && \
make package_python
WORKDIR /khaiii/build/package_python
RUN source /opt/rh/devtoolset-7/enable && \
pip3 install .

# branch to run khaiii
FROM base AS runtime
COPY --from=build /usr/local/bin/khaiii /usr/local/bin/
COPY --from=build /usr/local/lib/libkhaiii.* /usr/local/lib/
COPY --from=build /usr/local/share/khaiii/ /usr/local/share/khaiii/
COPY --from=build /usr/local/include/khaiii/ /usr/local/include/khaiii/

ENV PYTHON_VER=3.6
ARG KHAIII_VER
RUN echo "KHAIII_VER: ${KHAIII_VER}"
RUN if [ "${KHAIII_VER}" = "" ]; then echo "build argument KHAIII_VER is not provided" && exit 1; fi
COPY --from=build /usr/local/lib/python${PYTHON_VER}/site-packages/khaiii/ /usr/local/lib/python${PYTHON_VER}/site-packages/khaiii/
COPY --from=build /usr/local/lib/python${PYTHON_VER}/site-packages/khaiii-${KHAIII_VER}.dist-info/ /usr/local/lib/python${PYTHON_VER}/site-packages/khaiii-${KHAIII_VER}.dist-info/

ENV LANG=en_US.UTF-8
WORKDIR /
37 changes: 37 additions & 0 deletions docker/Dockerfile.centos-8.3.2011
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM centos:8.3.2011 AS base

# install base packages
RUN yum -y install glibc-langpack-en glibc-langpack-ko python3 python3-pip
RUN pip3 install --upgrade pip wheel

# branch to build khaiii
FROM base AS build
RUN yum -y groupinstall "Development Tools"
RUN pip3 install cmake
COPY . /khaiii
WORKDIR /khaiii/build
RUN cmake .. && \
make -j && \
make resource && \
test/khaiii && \
make install && \
make package_python
WORKDIR /khaiii/build/package_python
RUN pip3 install .

# branch to run khaiii
FROM base AS runtime
COPY --from=build /usr/local/bin/khaiii /usr/local/bin/
COPY --from=build /usr/local/lib/libkhaiii.* /usr/local/lib/
COPY --from=build /usr/local/share/khaiii/ /usr/local/share/khaiii/
COPY --from=build /usr/local/include/khaiii/ /usr/local/include/khaiii/

ENV PYTHON_VER=3.6
ARG KHAIII_VER
RUN echo "KHAIII_VER: ${KHAIII_VER}"
RUN if [ "${KHAIII_VER}" = "" ]; then echo "build argument KHAIII_VER is not provided" && exit 1; fi
COPY --from=build /usr/local/lib/python${PYTHON_VER}/site-packages/khaiii/ /usr/local/lib/python${PYTHON_VER}/site-packages/khaiii/
COPY --from=build /usr/local/lib/python${PYTHON_VER}/site-packages/khaiii-${KHAIII_VER}.dist-info/ /usr/local/lib/python${PYTHON_VER}/site-packages/khaiii-${KHAIII_VER}.dist-info/

ENV LANG=ko_KR.UTF-8
WORKDIR /
8 changes: 8 additions & 0 deletions docker/Dockerfile.pytorch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM pytorch/pytorch:1.7.0-cuda11.0-cudnn8-runtime

RUN pip install tensorboardX tqdm
COPY . /khaiii
WORKDIR /khaiii/train
ENV PYTHONPATH=/khaiii/src/main/python
RUN python split_corpus.py --input corpus/sample.txt --out-pfx corpus/sample --dev 4 --test 4
RUN python train.py --in-pfx corpus/sample --batch-size 4
52 changes: 52 additions & 0 deletions docker/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
ARG UBUNTU_VER="18.04"
FROM ubuntu:${UBUNTU_VER} AS base
# supported ubuntu versions are 20.04, 18.04 and 16.04
# you can build with passing --build-arg argument, such as "--build-arg UBUNTU_VER=20.04"

# install base packages
RUN apt -y update && \
apt -y install language-pack-ko python3 python3-pip
RUN locale-gen en_US.UTF-8 && \
update-locale LANG=en_US.UTF-8
RUN pip3 install --upgrade pip

# branch to build khaiii
FROM base AS build
RUN apt -y install build-essential
RUN pip3 install cmake
COPY . /khaiii
WORKDIR /khaiii/build
RUN cmake .. && \
make -j && \
make resource && \
test/khaiii && \
make install && \
make package_python
WORKDIR /khaiii/build/package_python
RUN pip3 install .

# branch to run khaiii
FROM base AS runtime
COPY --from=build /usr/local/bin/khaiii /usr/local/bin/
COPY --from=build /usr/local/lib/libkhaiii.* /usr/local/lib/
COPY --from=build /usr/local/share/khaiii/ /usr/local/share/khaiii/
COPY --from=build /usr/local/include/khaiii/ /usr/local/include/khaiii/

FROM runtime AS ubuntu-16.04
ENV PYTHON_VER=3.5

FROM runtime AS ubuntu-18.04
ENV PYTHON_VER=3.6

FROM runtime AS ubuntu-20.04
ENV PYTHON_VER=3.8

FROM ubuntu-${UBUNTU_VER}
ARG KHAIII_VER
RUN echo "KHAIII_VER: ${KHAIII_VER}"
RUN if [ "${KHAIII_VER}" = "" ]; then echo "build argument KHAIII_VER is not provided" && exit 1; fi
COPY --from=build /usr/local/lib/python${PYTHON_VER}/dist-packages/khaiii/ /usr/local/lib/python${PYTHON_VER}/dist-packages/khaiii/
COPY --from=build /usr/local/lib/python${PYTHON_VER}/dist-packages/khaiii-${KHAIII_VER}.dist-info/ /usr/local/lib/python${PYTHON_VER}/dist-packages/khaiii-${KHAIII_VER}.dist-info/

ENV LANG=ko_KR.UTF-8
WORKDIR /
36 changes: 0 additions & 36 deletions docker/README.md

This file was deleted.

28 changes: 0 additions & 28 deletions docker/for-continuumio-anaconda3-image/Dockerfile

This file was deleted.

58 changes: 0 additions & 58 deletions docker/pytorch-0.4.1/Dockerfile

This file was deleted.

58 changes: 0 additions & 58 deletions docker/pytorch-1.1.0/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cmake>=3.10
cmake>=3.12

0 comments on commit 5d1c727

Please sign in to comment.