Skip to content

Commit

Permalink
Merge pull request #3 from thisiscleverson/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
thisiscleverson authored Mar 29, 2024
2 parents 311f992 + 2513849 commit 707bcb2
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 16 deletions.
24 changes: 20 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
deploy:
sudo mv ~/http-server.service /etc/systemd/system/ \
&& sudo systemctl enable http-server \
&& sudo systemctl restart http-server \
start-docker:
docker compose up -d

start-service:
sudo systemctl start app

stop:
docker compose down

status:
sudo systemctl status app

build:
docker compose up --build &&\
docker compose down

deploy:
sudo cp ./app.service /etc/systemd/system/ && \
sudo systemctl enable app && \
sudo systemctl restart app
8 changes: 4 additions & 4 deletions http-server.service → app.service
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[Unit]
Description=My Docker Application
Description=Start docker compose Application
Requires=docker.service
After=docker.service

[Service]
Restart=always
ExecStart=/usr/local/bin/docker-compose -f /var/www/blog/docker-compose.yml up
ExecStop=/usr/local/bin/docker-compose -f /var/www/blog/docker-compose.yml down
ExecStart=/usr/local/bin/docker-compose -f /var/www/blog/docker-compose.yml up -d
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ services:
image: nginx:latest
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- /etc/letsencrypt:/etc/letsencrypt:ro
environment:
- FLASK_SERVER_ADDR=app:5000
- DOMAIN=cleverson.online
depends_on:
- app
ports:
- "80:80"
- "80:80"
- "443:443"

app:
build:
Expand Down
34 changes: 27 additions & 7 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
events {}

http {
access_log on;
sendfile on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

server {
listen 80;
server_name localhost;

listen [::]:80;

server_name $DOMAIN www.$DOMAIN;

location / {
proxy_pass http://app:5000;
proxy_pass http://$FLASK_SERVER_ADDR;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}

server {
listen [::]:443 ssl http2;
listen 443 ssl http2;
server_name $DOMAIN www.$DOMAIN;

ssl_certificate /etc/letsencrypt/live/$DOMAIN/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/$DOMAIN/privkey.pem;

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_pass http://$FLASK_SERVER_ADDR;
}

}
}

0 comments on commit 707bcb2

Please sign in to comment.