Skip to content

Commit

Permalink
Merge pull request #1 from likesistemas/feature/ssl-support
Browse files Browse the repository at this point in the history
✨ [GEST-2855] Configurando SSL no apache
  • Loading branch information
ricardoapaes authored Feb 17, 2025
2 parents 3ba0135 + 3e1ab30 commit b732aa0
Show file tree
Hide file tree
Showing 8 changed files with 382 additions and 576 deletions.
43 changes: 36 additions & 7 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,25 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Run tests
- name: Up environment
run: |
docker-compose up --build -d
docker compose up --build -d
- name: Wait environment
run: |
docker run -t --network apache jwilder/dockerize \
-wait http://apache_apache/ \
-timeout 120s
- name: Logs environment
run: |
docker compose ps
docker compose logs apache
docker-compose ps
docker-compose logs apache
- name: Run tests
run: |
CONTENT=$(curl -s "http://127.0.0.1/");
CONTENT_PHP=$(curl -s "http://127.0.0.1/script.php");
CONTENT_REWRITE=$(curl -s "http://127.0.0.1/rewrite/apache.php");
Expand All @@ -52,6 +57,30 @@ jobs:
exit 1;
fi
- name: Run tests in https
run: |
CONTENT=$(curl -k -s "https://127.0.0.1/");
CONTENT_PHP=$(curl -k -s "https://127.0.0.1/script.php");
CONTENT_REWRITE=$(curl -k -s "https://127.0.0.1/rewrite/apache.php");
echo "CHAMADA HTTP NORMAL: ${CONTENT}";
echo "CHAMADA HTTP PHP: ${CONTENT_PHP}";
echo "CHAMADA HTTP REWRITE: ${CONTENT_REWRITE}";
if [ "${CONTENT}" != "html" ]; then
echo "Chamada HTTP NORMAL retornou errado: ${CONTENT}"
exit 1;
fi

if [ "${CONTENT_PHP}" != "php" ]; then
echo "Chamada HTTP TRYFILES retornou errado: ${CONTENT_PHP}"
exit 1;
fi

if [ "${CONTENT_REWRITE}" != "/rewrite/apache.php" ]; then
echo "Chamada HTTP REWRITE retornou errado: ${CONTENT_REWRITE}"
exit 1;
fi

push:
needs: test

Expand Down
15 changes: 14 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
FROM debian:10-slim AS ssl
WORKDIR /ssl/
RUN apt update && apt-get install -y libnss3-tools curl
RUN curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64"
RUN chmod +x mkcert-v*-linux-amd64
RUN mv mkcert-v*-linux-amd64 /usr/local/bin/mkcert
RUN mkcert -key-file server.key -cert-file server.crt localhost 127.0.0.1 ::1

FROM httpd:2.4

ENV DOCKERIZE_VERSION v0.6.1
Expand All @@ -9,8 +17,13 @@ RUN apt-get update && apt-get install -y wget \
ENV PORTA_PHP=9000
ENV TIMEOUT_PHP=60s

COPY httpd.conf /usr/local/apache2/conf/httpd.conf
COPY httpd-vhosts.conf /usr/local/apache2/conf/extra/httpd-vhosts.conf
COPY httpd-ssl.conf /usr/local/apache2/conf/extra/httpd-ssl.conf
COPY httpd-php.conf /usr/local/apache2/conf/extra/httpd-php.conf

COPY --from=ssl /ssl/server.crt /usr/local/apache2/conf/server.crt
COPY --from=ssl /ssl/server.key /usr/local/apache2/conf/server.key
RUN ls -la /usr/local/apache2/conf/

COPY sh/ /usr/local/bin/
RUN chmod +x /usr/local/bin/start
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.5'
networks:
apache:
name: apache
Expand All @@ -17,17 +16,18 @@ services:
- apache

apache:
image: likesistemas/apache:dev
build: .
container_name: apache_apache
environment:
- HOST_PHP=apache_app
- PORTA_PHP=9000
- SSL=true
ports:
- 80:80
- 443:443
volumes:
- ./www/:/var/www/public/
links:
- app
depends_on:
- app
networks:
Expand Down
3 changes: 3 additions & 0 deletions httpd-php.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<FilesMatch \.php$>
SetHandler "proxy:fcgi://{{ default .Env.HOST_PHP "php" }}:{{ .Env.PORTA_PHP }}"
</FilesMatch>
Loading

0 comments on commit b732aa0

Please sign in to comment.