Skip to content
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
56 changes: 56 additions & 0 deletions Dockerfile_uwsgi.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Base OS with Python and tools
FROM debian:latest
# Metadata: Wenjing Ma
LABEL MAINTAINER="mawenjing1993@gmail.com"

# Update OS
RUN apt-get update -y

# Install Python + build tools (keep as-is, just drop Apache)
RUN apt-get update && apt-get install -y \
build-essential \
python3 \
python3-dev \
python3-pip \
vim \
&& apt-get clean \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*

# Install uwsgi
RUN pip3 install --no-cache-dir --break-system-packages uwsgi

# App deps
COPY ./requirements.txt /BARTweb/requirements.txt
RUN pip3 install --break-system-packages -r /BARTweb/requirements.txt

# App code
RUN mkdir -p /BARTweb
COPY . /BARTweb/

# Prepare a writable usercase root (same fix that solved the 500)
RUN mkdir -p /BARTweb/usercase \
&& chown -R www-data:www-data /BARTweb/usercase \
&& chmod -R 775 /BARTweb/usercase

# Logs
RUN mkdir -p /log /BARTweb/usercase/log \
&& touch /log/bartweb.log /BARTweb/usercase/log/bartweb.log \
&& chown -R www-data:www-data /log /BARTweb/usercase/log \
&& chmod -R 775 /BARTweb/usercase/log

WORKDIR /BARTweb/

# Root stuff
# Create a non-root user and group called "app"
RUN groupadd -g 1001 app && useradd -u 1001 -g app -m app
# Give ownersip of app + log dirs to user
RUN chown -R app:app /BARTweb /log
# Switch to new user
USER app

# Flask default port
EXPOSE 5000

# Run Flask app (app.py already has host='0.0.0.0')
CMD ["uwsgi", "--ini", "uwsgi.ini"]
15 changes: 10 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ def help():
logger.error("Retrieve result: did not find the result.")
err_msg = "Job does not exist, make sure you enter the right key."
return redirect(url_for('error_page', msg=err_msg))

return render_template('help.html')


#############################################

@app.route('/result', methods=['GET', 'POST'])
Expand Down Expand Up @@ -291,6 +291,11 @@ def get_result():

results = parseIO.generate_results(user_data)
results['sample'] = False

## @marvinquite 02/25/2024, debug purpose
# logger.info(results)
## Results can be accurately retrieved 04/16/2024
## end
return render_template('result_demonstration.html', results=results, key=request.args['user_key'])

@app.route('/error', methods=['GET', 'POST'])
Expand Down Expand Up @@ -333,10 +338,10 @@ def download_sample_file(sample_type):
if sample_type == 'genelist':
sample_name = "genelist.txt"
sample_path = os.path.join(PROJECT_DIR, 'sample/genelist/upload')
elif sample_type == 'ChIPseq.bam':
elif sample_type == 'ChIPdata':
sample_name = "ChIPseq.bam"
sample_path = os.path.join(PROJECT_DIR, 'sample/ChIPdata')
elif sample_type == 'ChIPpeaks.bed':
sample_path = os.path.join(PROJECT_DIR, 'sample/ChIPdata/upload')
elif sample_type == 'ChIPpeaks':
sample_name = "ChIPpeaks.bed"
sample_path = os.path.join(PROJECT_DIR, 'sample/Region')

Expand All @@ -351,7 +356,7 @@ def sample_result(sample_type):

user_data = {}
with open(config_file, 'r') as fopen:
user_data = yaml.load(fopen)
user_data = yaml.load(fopen, Loader=yaml.FullLoader)

if user_data:
results = parseIO.generate_results(user_data)
Expand Down
31 changes: 7 additions & 24 deletions Dockerfile → archived/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
FROM debian:latest
MAINTAINER Yifan Zhang

# Update OS
RUN apt-get update -y

# Install Python other things
#RUN apt-get install -y python-pip python-dev build-essential
RUN apt-get update && apt-get install -y apache2 \
libapache2-mod-wsgi-py3 \
build-essential \
python3 \
python3-dev\
python3-pip \
vim \
&& apt-get clean \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*

# && do not continue if any fails

# FROM Dockerfile_debian_20240506_fixed # not sure if this would be the correct name for it
# MAINTAINER Wenjing Ma mawenjing1993@gmail.com

# ADD . /app
COPY ./requirements.txt /BARTweb/requirements.txt
# RUN pip install uwsgi
RUN pip3 install -r /BARTweb/requirements.txt
RUN pip3 install --break-system-packages -r /BARTweb/requirements.txt

# Copy over the apache configuration file and enable the site
COPY ./apache-flask.conf /etc/apache2/sites-available/apache-flask.conf
Expand All @@ -42,12 +23,14 @@ EXPOSE 80
# ENV HOME /app change to apache-flask
WORKDIR /BARTweb/

# For log
# For log -> in 20230401j docker image
RUN mkdir /log && touch /log/bartweb.log
RUN chown -R www-data:www-data /log
# original For log
RUN mkdir -p usercase/log
RUN touch usercase/log/bartweb.log
RUN chown -R www-data:www-data usercase/log
RUN chmod -R 775 usercase/log

#run apache, this directory is present with installation of apache
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]

20 changes: 20 additions & 0 deletions archived/Dockerfile_debian_20240506_fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM debian:latest
MAINTAINER Wenjing Ma mawenjing1993@gmail.com

# Update OS
RUN apt-get update -y

# Install Python other things
#RUN apt-get install -y python-pip python-dev build-essential
RUN apt-get update && apt-get install -y apache2 \
libapache2-mod-wsgi-py3 \
build-essential \
python3 \
python3-dev\
python3-pip \
vim \
&& apt-get clean \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*

# && do not continue if any fails
File renamed without changes.
File renamed without changes.
Loading