diff --git a/.github/workflows/publish_prod_project.yml b/.github/workflows/publish_prod_project.yml index e7dc309..8f12003 100644 --- a/.github/workflows/publish_prod_project.yml +++ b/.github/workflows/publish_prod_project.yml @@ -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 \ No newline at end of file + ./scripts/dp-react.prod.sh \ No newline at end of file diff --git a/Dockerfile-Production b/Dockerfile-Production index 048af39..e2babea 100644 --- a/Dockerfile-Production +++ b/Dockerfile-Production @@ -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;"] \ No newline at end of file diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 16a422b..aa329c3 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -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 diff --git a/nginx.conf b/nginx.conf index 5efef01..da25bca 100644 --- a/nginx.conf +++ b/nginx.conf @@ -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; } -} \ No newline at end of file +} diff --git a/nginx.https.conf b/nginx.https.conf new file mode 100644 index 0000000..5efef01 --- /dev/null +++ b/nginx.https.conf @@ -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; + } +} \ No newline at end of file