Skip to content

Commit

Permalink
Merge pull request #653 from replicatedhq/joshs/SC-109666-2
Browse files Browse the repository at this point in the history
Update Nginx
  • Loading branch information
divolgin authored Oct 18, 2024
2 parents fe379a6 + 6bc9cee commit dfe96f2
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 32 deletions.
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

0 comments on commit dfe96f2

Please sign in to comment.