Skip to content

Commit

Permalink
Merge pull request #37 from alexfariakof/feature/Change-Production-Se…
Browse files Browse the repository at this point in the history
…rver-Port

Feature/Change Production Server Port to 3000
  • Loading branch information
alexfariakof authored Dec 13, 2023
2 parents 6d17286 + 334ea50 commit b86ef82
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 44 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/publish_prod_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,4 @@ jobs:
key: ${{ secrets.AWS_SSH_KEY }}
port: 22
script: |
IMAGEM="${{ secrets.DOCKER_IMAGE_PROD }}"
container_id=$(docker ps -a -q --filter "ancestor=$IMAGEM")
image_id=$(docker images --format "{{.ID}}" "$IMAGEM")
docker login -u ${{ secrets.DOCKER_LOGIN }} -p ${{ secrets.DOCKER_PASSWORD }}
docker rm --force $container_id
docker rmi --force $image_id
docker pull $IMAGEM
image_id=$(docker images --format "{{.ID}}" "$IMAGEM")
docker run -d -p 80:80 $IMAGEM
./scripts/dp-react.prod.sh
10 changes: 4 additions & 6 deletions Dockerfile-Production
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ RUN npm install && mv node_modules ../
COPY . ./
RUN npm run build

EXPOSE 3000
# production env
FROM nginx:stable-alpine
COPY --from=build /app/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Gerando Certificado SSL
RUN apk add --no-cache openssl
COPY ./certificate/openssl.cnf /etc/nginx/certificate/openssl.cnf
RUN openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -keyout /etc/nginx/certificate/ssl_certificate_key.pem -out /etc/nginx/certificate/ssl_certificate.pem -config /etc/nginx/certificate/openssl.cnf

EXPOSE 80
EXPOSE 443
#RUN apk add --no-cache openssl
#COPY ./certificate/openssl.cnf /etc/nginx/certificate/openssl.cnf
#RUN openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -keyout /etc/nginx/certificate/ssl_certificate_key.pem -out /etc/nginx/certificate/ssl_certificate.pem -config /etc/nginx/certificate/openssl.cnf
CMD ["nginx", "-g", "daemon off;"]
5 changes: 2 additions & 3 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ version: '3.4'

services:
despesas-frontend-react:
container_name: prod
container_name: prod-react
image: alexfariakof/despesas-pessoais-react-img
working_dir: /usr/share/nginx/html
build:
context: .
dockerfile: ./Dockerfile-Production
ports:
- 80:80
- 443:443
- 3000:3000
restart: always
environment:
NODE_ENV: production
Expand Down
28 changes: 2 additions & 26 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -1,34 +1,10 @@
server {
listen 80;
server_name _;

location / {
return 301 https://$host$request_uri;
}
}

server {
listen 443 ssl;
server_name alexfariakof.com;

ssl_certificate /etc/nginx/certificate/ssl_certificate.pem;
ssl_certificate_key /etc/nginx/certificate/ssl_certificate_key.pem;

listen 3000;
root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri $uri/ /index.html;
}
}

server {
listen 80 default_server;
server_name _;

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
}
}
34 changes: 34 additions & 0 deletions nginx.https.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
server {
listen 80;
server_name _;

location / {
return 301 https://$host$request_uri;
}
}

server {
listen 443 ssl;
server_name alexfariakof.com;

ssl_certificate /etc/nginx/certificate/ssl_certificate.pem;
ssl_certificate_key /etc/nginx/certificate/ssl_certificate_key.pem;

root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri $uri/ /index.html;
}
}

server {
listen 80 default_server;
server_name _;

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
}

0 comments on commit b86ef82

Please sign in to comment.