Skip to content

Commit

Permalink
Merge branch 'AliroGPT' of https://github.com/jay-m-dev/AliroGPT into…
Browse files Browse the repository at this point in the history
… AliroGPT
  • Loading branch information
HyunjunA committed Jul 27, 2023
2 parents 58cf6b8 + 1314758 commit e9f62b7
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 89 deletions.
47 changes: 23 additions & 24 deletions docker/dbmongo/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
FROM mongo:4.4.18
# Stage 1: Build stage with all necessary files
FROM mongo:4.4.18 AS builder

WORKDIR /opt/

ARG docker_filepath=docker/dbmongo/files

RUN apt-get update && apt-get install -y dos2unix

# RUN apt-get update
# RUN apt-get install gpg wget
# RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
# RUN apt-get update


#add repo for mongodb
# RUN echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.2.list
# RUN apt-get update --fix-missing && \
# apt-get install -y --allow-unauthenticated \
# vim mongodb-org npm openssh-client htop dos2unix \
# net-tools iputils-ping \
# --no-install-recommends && \
# apt-get clean && \
# rm -rf /var/lib/apt/lists/*

#check if we need to rebuild
# Copy necessary files
COPY ${docker_filepath}/mongod.conf /etc/
COPY ${docker_filepath}/users.json /root/
COPY ${docker_filepath}/projects.json /root/
COPY ${docker_filepath}/entrypoint.sh /root/
COPY ${docker_filepath}/sync.sh /root/
RUN dos2unix /root/entrypoint.sh /root/sync.sh
RUN dos2unix /root/users.json /root/projects.json
RUN dos2unix /etc/mongod.conf
RUN apt-get remove -y dos2unix && apt-get clean

# Convert line endings for DOS/Windows compatibility
RUN apt-get update && apt-get install -y dos2unix && \
dos2unix /root/entrypoint.sh /root/sync.sh /root/users.json /root/projects.json && \
dos2unix /etc/mongod.conf && \
apt-get remove -y dos2unix && \
apt-get autoremove -y && \
apt-get clean

# Stage 2: Final runtime image
FROM mongo:4.4.18

# Copy required configurations and scripts from the builder stage
COPY --from=builder /etc/mongod.conf /etc/
COPY --from=builder /root/entrypoint.sh /root/
COPY --from=builder /root/sync.sh /root/
COPY --from=builder /root/users.json /root/
COPY --from=builder /root/projects.json /root/

EXPOSE 27017

CMD ["/bin/bash", "/root/entrypoint.sh"]

99 changes: 52 additions & 47 deletions docker/lab/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FROM python:3.7.16-slim-buster
# Stage 1: Build and compile dependencies
FROM python:3.7.16-slim-buster AS builder

ARG USE_WHEELS
ARG wheel_directory=docker/wheels
ARG docker_filepath=docker/lab/files

RUN apt-get update --fix-missing && \
apt-get install -y wget xz-utils git \
Expand Down Expand Up @@ -30,20 +32,7 @@ RUN apt-get update --fix-missing && \
apt-get remove -y wget && \
apt-get clean

ARG docker_filepath=docker/lab/files

# RUN apt-get update --fix-missing && apt-get install -y \
# vim openssh-client openssh-server telnet apache2 \
# net-tools iputils-ping xz-utils \
# screen ngrep ca-cacert \
# mercurial subversion \
# build-essential cmake lsb-core cpio mesa-common-dev \
# dos2unix \
# --no-install-recommends && \
# apt-get clean && \
# rm -rf /var/lib/apt/lists/*

# setup python environment
# Setup python environment
RUN mkdir /root/wheel
COPY ${wheel_directory}/*.whl /root/wheel/
COPY ${docker_filepath}/requirements.txt /root/
Expand All @@ -53,9 +42,9 @@ RUN if [ ${USE_WHEELS} -eq 1 ] ; \
fi
RUN rm /root/wheel/*.whl

# these requirements need to be built, using wheels throws errors
COPY ${docker_filepath}/requirements-build.txt /root/
RUN pip install --no-cache-dir -r /root/requirements-build.txt
# # These requirements need to be built, using wheels throws errors
# COPY ${docker_filepath}/requirements-build.txt /root/
# RUN pip install --no-cache-dir -r /root/requirements-build.txt

## Webserver
RUN rm /etc/apache2/sites-enabled/*
Expand All @@ -69,60 +58,76 @@ RUN cp /etc/apache2/mods-available/rewrite* /etc/apache2/mods-enabled \
&& cp /etc/apache2/mods-available/headers.load /etc/apache2/mods-enabled \
&& cp /etc/apache2/mods-available/expires.load /etc/apache2/mods-enabled

# setup node environment
# Setup node environment
RUN npm install -g pm2 --silent --progress=false

# install lab/webapp/node_modules to an anon volume
# Install lab/webapp/node_modules to an anonymous volume
WORKDIR /appsrc/lab/webapp
COPY lab/webapp/package.json /appsrc/lab/webapp/
COPY lab/webapp/package-lock.json /appsrc/lab/webapp/
RUN dos2unix /appsrc/lab/webapp/*.json
RUN npm install --silent --progress=false

# install lab/node_modules to an anon volume
# Install lab/node_modules to an anonymous volume
WORKDIR /appsrc/lab
COPY lab/package.json /appsrc/lab/
COPY lab/package-lock.json /appsrc/lab/
RUN dos2unix /appsrc/lab/*.json
RUN npm install --silent --progress=false

COPY ${docker_filepath}/001-pennai.conf /etc/apache2/sites-enabled/
COPY ${docker_filepath}/htpasswd /etc/apache2/htpasswd
COPY ${docker_filepath}/certs/* /usr/lib/ssl/private/
# Stage 2: Final runtime image
FROM python:3.7.16-slim-buster

WORKDIR /root/
ARG docker_filepath=docker/lab/files

# Webserver - paiwww
COPY ${docker_filepath}/start.sh /root/
# Copy installed packages from the builder stage
COPY --from=builder /usr/local /usr/local

## Utility script, used when starting ai
COPY ${docker_filepath}/wait-for-it.sh /root/
RUN ["chmod", "+x", "/root/wait-for-it.sh"]
# Copy Apache configuration
COPY --from=builder /etc/apache2 /etc/apache2

# Copy webapp and lab source code
COPY --from=builder /appsrc/lab /appsrc/lab

## Aliro Lab server
# Copy scripts and other files
COPY ${docker_filepath}/start.sh /root/
COPY ${docker_filepath}/wait-for-it.sh /root/
COPY ${docker_filepath}/entrypoint.sh /root/
RUN ["chmod", "+x", "/root/entrypoint.sh"]

RUN dos2unix /root/start.sh \
&& dos2unix /root/wait-for-it.sh \
&& dos2unix /root/entrypoint.sh

# set version and build environment; tag.sh is sourced in entrypoint.sh
ENV BUILD_ENV='dev'
COPY ${docker_filepath}/001-pennai.conf /etc/apache2/sites-enabled/
COPY ${docker_filepath}/htpasswd /etc/apache2/htpasswd
COPY ${docker_filepath}/certs/* /usr/lib/ssl/private/
COPY .env /etc/profile.d/
RUN cp '/etc/profile.d/.env' '/etc/profile.d/tag.sh'
RUN dos2unix /etc/profile.d/tag.sh
RUN sed -i "s/TAG=/export TAG=/g" /etc/profile.d/tag.sh

# clean up
RUN apt-get remove -y wget xz-utils
# These requirements need to be built, using wheels throws errors
COPY ${docker_filepath}/requirements-build.txt /root/

# Set version and build environment
ENV BUILD_ENV='dev'
RUN apt-get update && apt-get install -y dos2unix git build-essential && \
pip install --no-cache-dir -r /root/requirements-build.txt && \
cp '/etc/profile.d/.env' '/etc/profile.d/tag.sh' && \
dos2unix /etc/profile.d/tag.sh && \
sed -i "s/TAG=/export TAG=/g" /etc/profile.d/tag.sh && \
rm -rf /var/lib/apt/lists/* && \
apt-get remove -y dos2unix git build-essential && \
apt-get autoremove -y && \
apt-get clean && \
chmod +x /root/*.sh
# rm -rf /src/scikit-surprise
# RUN cp '/etc/profile.d/.env' '/etc/profile.d/tag.sh'
# RUN dos2unix /etc/profile.d/tag.sh
# RUN sed -i "s/TAG=/export TAG=/g" /etc/profile.d/tag.sh

# Clean up
# RUN apt-get remove -y wget xz-utils

# Expose ports and set working directory
EXPOSE 5080
WORKDIR /appsrc/lab/

# Start the webserver
CMD ["/bin/bash", "/root/start.sh"]

# EXPOSE 443
EXPOSE 5080
WORKDIR /appsrc/lab/
# Entrypoint
ENTRYPOINT ["/root/entrypoint.sh"]

4 changes: 2 additions & 2 deletions docker/lab/files/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
scikit-learn==0.23.2
scikit-learn==0.24.2
tqdm==4.64.1
pymongo==4.3.3
pandas==1.0.5
pandas==1.1.0
numpy==1.19.5
cython==0.29.32
xgboost==1.6.2
Expand Down
38 changes: 24 additions & 14 deletions docker/machine/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM python:3.7.16-slim-buster
# Stage 1: Build and install Python and Node.js dependencies
FROM python:3.7.16-slim-buster AS builder

ARG USE_WHEELS
ARG wheel_directory=docker/wheels
Expand Down Expand Up @@ -30,7 +31,7 @@ RUN apt-get update --fix-missing && apt-get install -y \
apt-get remove -y wget && \
apt-get clean

# setup python environment
# Setup python environment
RUN mkdir /root/wheel
COPY ${wheel_directory}/*.whl /root/wheel/
COPY ${docker_filepath}/requirements.txt /root/
Expand All @@ -40,28 +41,37 @@ RUN if [ ${USE_WHEELS} -eq 1 ] ; \
fi
RUN rm -rf /root/wheel

# these requirements need to be built, using wheels throws errors
# These requirements need to be built, using wheels throws errors
COPY ${docker_filepath}/requirements-build.txt /root/
RUN pip install --no-cache-dir -r /root/requirements-build.txt

# setup node environment
# Setup node environment
RUN npm install -g pm2 --silent --progress=false

# install node_modules to an anon volume
WORKDIR /appsrc/machine
# Stage 2: Final runtime image
FROM python:3.7.16-slim-buster

ARG docker_filepath=docker/machine/files

# Copy installed Python dependencies
COPY --from=builder /usr/local /usr/local

# Copy node_modules to an anonymous volume
WORKDIR /appsrc/machine
COPY machine/package.json /appsrc/machine/
COPY machine/package-lock.json /appsrc/machine/
RUN dos2unix /appsrc/machine/*.json
RUN npm install --silent --progress=false

# Copy entrypoint script and other files
COPY ${docker_filepath}/entrypoint.sh /root/
COPY ${docker_filepath}/wait-for-it.sh /root/
RUN dos2unix /root/wait-for-it.sh && dos2unix /root/entrypoint.sh

# clean up
RUN apt-get remove -y wget xz-utils

RUN ["chmod", "+x", "/root/wait-for-it.sh"]
RUN apt-get update && apt-get install -y graphviz dos2unix && \
dos2unix /appsrc/machine/*.json && \
npm install --silent --progress=false && \
dos2unix /root/wait-for-it.sh && dos2unix /root/entrypoint.sh && \
chmod +x /root/wait-for-it.sh && chmod +x /root/entrypoint.sh && \
apt-get remove -y dos2unix && \
apt-get clean
# apt-get autoremove -y && \

CMD ["/bin/bash", "/root/entrypoint.sh"]

4 changes: 2 additions & 2 deletions docker/machine/files/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
scikit-learn==0.23.2
scikit-learn==0.24.2
tqdm==4.64.1
pymongo==4.3.3
pandas==1.0.5
pandas==1.1.0
numpy==1.19.5
matplotlib==3.5.3
mlxtend==0.16.0
Expand Down

0 comments on commit e9f62b7

Please sign in to comment.