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

Update Nginx #653

Merged
merged 4 commits into from
Oct 18, 2024
Merged
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
6 changes: 2 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
38 changes: 30 additions & 8 deletions deploy/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]
44 changes: 25 additions & 19 deletions nginx-app.conf
Original file line number Diff line number Diff line change
@@ -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
}
}
}
6 changes: 5 additions & 1 deletion supervisor-app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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