diff --git a/.circleci/config.yml b/.circleci/config.yml index 3a53f428..f8211c2d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -150,8 +150,7 @@ jobs: <<: *defaults steps: - checkout - - setup_remote_docker: - version: "20.10.23" + - setup_remote_docker - run: | export WORKDIR=`pwd` export CIRCLE_PROJECT_REPONAME=$PROJECT_NAME @@ -171,8 +170,7 @@ jobs: ECR_REPO: 799720048698.dkr.ecr.us-east-1.amazonaws.com steps: - checkout - - setup_remote_docker: - version: "20.10.23" + - setup_remote_docker - run: | export WORKDIR=`pwd` export CIRCLE_PROJECT_REPONAME=$PROJECT_NAME diff --git a/deploy/Dockerfile.prod b/deploy/Dockerfile.prod index dc3588e3..b6b16306 100644 --- a/deploy/Dockerfile.prod +++ b/deploy/Dockerfile.prod @@ -1,4 +1,4 @@ -FROM golang:1.20 as builder +FROM golang:1.20 AS builder WORKDIR /docker-compose-generate COPY ./util/docker-compose-generate /docker-compose-generate RUN make build @@ -9,28 +9,50 @@ COPY --from=builder /docker-compose-generate/dcg /dcg RUN apt-get update \ && apt-get install -y --no-install-recommends \ git \ - nginx \ + build-essential \ + libpcre3 \ + libpcre3-dev \ + zlib1g \ + zlib1g-dev \ + libssl-dev \ supervisor \ && rm -rf /var/lib/apt/lists/* +WORKDIR /tmp +RUN curl -O http://nginx.org/download/nginx-1.24.0.tar.gz \ + && tar -zxvf nginx-1.24.0.tar.gz \ + && cd nginx-1.24.0 \ + && ./configure \ + --with-http_ssl_module \ + --with-http_v2_module \ + --with-http_gzip_static_module \ + && make \ + && make install \ + && rm -rf /tmp/nginx-1.24.0* + +# Add Nginx binary location to PATH +ENV PATH="/usr/local/nginx/sbin:$PATH" + +# Set up Nginx and Supervisor configurations +RUN rm /usr/local/nginx/conf/nginx.conf +ADD ./nginx-app.conf /usr/local/nginx/conf/nginx.conf +ADD ./supervisor-app.conf /etc/supervisor/conf.d/ + +# Copy Python app files ADD ./requirements.txt /home/docker/code/ RUN pip install -r /home/docker/code/requirements.txt -RUN echo "daemon off;" >> /etc/nginx/nginx.conf -RUN rm /etc/nginx/sites-enabled/default -ADD ./nginx-app.conf /etc/nginx/sites-enabled/ -ADD ./supervisor-app.conf /etc/supervisor/conf.d/ - ADD ./uwsgi_params /home/docker/code/ ADD ./uwsgi.ini /home/docker/code/ - ADD ./install_scripts /home/docker/code/install_scripts/ ADD ./main.py /home/docker/code/ ADD Manifest /home/docker/code/ ADD LICENSE /home/docker/code/ +# Generate Docker compose template RUN /dcg --raw > /home/docker/code/install_scripts/templates/swarm/docker-compose-generate-safe.sh +# Expose Nginx port EXPOSE 80 CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf", "-n"] diff --git a/nginx-app.conf b/nginx-app.conf index 4d149a1b..fd037c3a 100644 --- a/nginx-app.conf +++ b/nginx-app.conf @@ -1,27 +1,33 @@ # mysite_nginx.conf -# the upstream component nginx needs to connect to -upstream flask { - server unix:/tmp/app.sock; # for a file socket - # server 127.0.0.1:8001; # for a web port socket (we'll use this first) +events { + worker_connections 1024; } -# configuration of the server -server { - # the port your site will be served on, default_server indicates that this server block - # is the block to use if no blocks match the server_name - listen 80 default_server; +http { + # the upstream component nginx needs to connect to + upstream flask { + server unix:/tmp/app.sock; # for a file socket + # server 127.0.0.1:8001; # for a web port socket (we'll use this first) + } - # the domain name it will serve for - server_name get.replicated.com; # substitute your machine's IP address or FQDN - charset utf-8; + # configuration of the server + server { + # the port your site will be served on, default_server indicates that this server block + # is the block to use if no blocks match the server_name + listen 80 default_server; - # max upload size - client_max_body_size 75M; # adjust to taste + # the domain name it will serve for + server_name get.replicated.com; # substitute your machine's IP address or FQDN + charset utf-8; - # Finally, send all non-media requests to the Flask server. - location / { - uwsgi_pass flask; - include /home/docker/code/uwsgi_params; # the uwsgi_params file you installed - } + # max upload size + client_max_body_size 75M; # adjust to taste + + # Finally, send all non-media requests to the Flask server. + location / { + uwsgi_pass flask; + include /home/docker/code/uwsgi_params; # the uwsgi_params file you installed + } + } } diff --git a/supervisor-app.conf b/supervisor-app.conf index cdd76172..3546a06d 100644 --- a/supervisor-app.conf +++ b/supervisor-app.conf @@ -6,4 +6,8 @@ stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 [program:nginx-app] -command = /usr/sbin/nginx +command = /usr/local/nginx/sbin/nginx -g "daemon off;" +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0