Skip to content

Commit 54dba50

Browse files
committed
Added a docker stack to easily run the servers for the Approov Integration examples.
Signed-off-by: Exadra37 <exadra37@gmail.com>
1 parent 9b1dfbd commit 54dba50

File tree

3 files changed

+188
-0
lines changed

3 files changed

+188
-0
lines changed

Dockerfile

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
ARG TAG=8.1.4-cli
2+
3+
FROM php:${TAG}
4+
5+
ARG CONTAINER_USER="developer"
6+
ARG LANGUAGE_CODE="en"
7+
ARG COUNTRY_CODE="GB"
8+
ARG ENCODING="UTF-8"
9+
10+
ARG LOCALE_STRING="${LANGUAGE_CODE}_${COUNTRY_CODE}"
11+
ARG LOCALIZATION="${LOCALE_STRING}.${ENCODING}"
12+
13+
ARG OH_MY_ZSH_THEME="bira"
14+
15+
RUN apt update && apt -y upgrade && \
16+
apt -y install \
17+
locales \
18+
git \
19+
curl \
20+
inotify-tools \
21+
zip \
22+
unzip \
23+
zsh && \
24+
25+
echo "${LOCALIZATION} ${ENCODING}" > /etc/locale.gen && \
26+
locale-gen "${LOCALIZATION}" && \
27+
28+
useradd -m -u 1000 -s /usr/bin/zsh "${CONTAINER_USER}" && \
29+
30+
bash -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" && \
31+
32+
cp -v /root/.zshrc /home/"${CONTAINER_USER}"/.zshrc && \
33+
cp -rv /root/.oh-my-zsh /home/"${CONTAINER_USER}"/.oh-my-zsh && \
34+
sed -i "s/\/root/\/home\/${CONTAINER_USER}/g" /home/"${CONTAINER_USER}"/.zshrc && \
35+
sed -i s/ZSH_THEME=\"robbyrussell\"/ZSH_THEME=\"${OH_MY_ZSH_THEME}\"/g /home/${CONTAINER_USER}/.zshrc && \
36+
mkdir /home/"${CONTAINER_USER}"/workspace && \
37+
chown -R "${CONTAINER_USER}":"${CONTAINER_USER}" /home/"${CONTAINER_USER}"
38+
39+
USER ${CONTAINER_USER}
40+
41+
ENV USER ${CONTAINER_USER}
42+
ENV LANG "${LOCALIZATION}"
43+
ENV LANGUAGE "${LOCALE_STRING}:${LANGUAGE_CODE}"
44+
ENV PATH=/home/${CONTAINER_USER}/.local/bin:${PATH}
45+
ENV LC_ALL "${LOCALIZATION}"
46+
47+
WORKDIR /home/${CONTAINER_USER}/workspace
48+
49+
RUN mkdir -p /home/${CONTAINER_USER}/.local/bin && \
50+
curl https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet && \
51+
mv composer.phar /home/${CONTAINER_USER}/.local/bin/composer && \
52+
composer about
53+
54+
CMD ["zsh"]

EXAMPLES.md

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Approov Integrations Examples
2+
3+
[Approov](https://approov.io) is an API security solution used to verify that requests received by your backend services originate from trusted versions of your mobile apps, and here you can find the Hello servers examples that are the base for the Approov [quickstarts](/docs) for the Laravel PHP Framework.
4+
5+
For more information about how Approov works and why you should use it you can read the [README](/README.md) at the root of this repo.
6+
7+
If you are looking for the Approov quickstarts to integrate Approov in your Laravel API server then you can find them [here](/docs).
8+
9+
10+
## Hello Server Examples
11+
12+
To learn more about each Hello server example you need to read the README for each one at:
13+
14+
* [Unprotected Server](./src/unprotected-server/hello)
15+
* [Approov Protected Server - Token Check](./src/approov-protected-server/token-check/hello)
16+
* [Approov Protected Server - Token Binding Check](./src/approov-protected-server/token-binding-check/hello)
17+
18+
19+
## Docker Stack
20+
21+
The docker stack provided via the `docker-compose.yml` file in this folder is used for development proposes and if you are familiar with docker then feel free to also use it to follow along the examples on the README of each server.
22+
23+
If you decide to use the docker stack then you need to bear in mind that the Postman collections, used to test the servers examples, will connect to port `8002` therefore you cannot start all docker compose services at once, for example with `docker-compose up`, instead you need to run one at a time as exemplified below.
24+
25+
### Setup Env File
26+
27+
Do not forget to properly setup the `.env` file in the root of each Approov protected server example before you run the server with the docker stack.
28+
29+
```bash
30+
cp src/unprotected-server/hello/.env.example src/unprotected-server/hello/.env
31+
cp src/approov-protected-server/token-check/hello/.env.example src/approov-protected-server/token-check/hello/.env
32+
cp src/approov-protected-server/token-binding-check/hello/.env.example src/approov-protected-server/token-binding-check/hello/.env
33+
```
34+
35+
Edit each file and add the [dummy secret](/README.md#the-dummy-secret) to it in order to be able to test the Approov integration with the provided [Postman collection](https://github.com/approov/postman-collections/blob/master/quickstarts/hello-world/hello-world.postman_curl_requests_examples.md).
36+
37+
38+
### Build the Docker Stack
39+
40+
The three services in the `docker-compose.yml` use the same Dockerfile, therefore to build the Docker image we just need to used one of them:
41+
42+
```bash
43+
sudo docker-compose build approov-token-binding-check
44+
```
45+
46+
Now, you are ready to start using the Docker stack for Laravel PHP Framework.
47+
48+
49+
### Command Examples
50+
51+
To run each of the Hello servers with docker compose you just need to follow the respective example below.
52+
53+
#### For the unprotected server
54+
55+
Run the container attached to your machine bash shell:
56+
57+
```bash
58+
sudo docker-compose up unprotected-server
59+
```
60+
61+
or get a bash shell inside the container:
62+
63+
```bash
64+
sudo docker-compose run --rm --service-ports unprotected-server zsh
65+
```
66+
67+
#### For the Approov Token Check
68+
69+
Run the container attached to the shell:
70+
71+
```bash
72+
sudo docker-compose up approov-token-check
73+
```
74+
75+
or get a bash shell inside the container:
76+
77+
```bash
78+
sudo docker-compose run --rm --service-ports approov-token-check zsh
79+
```
80+
81+
#### For the Approov Token Binding Check
82+
83+
Run the container attached to the shell:
84+
85+
```bash
86+
sudo docker-compose up approov-token-binding-check
87+
```
88+
89+
or get a bash shell inside the container:
90+
91+
```bash
92+
sudo docker-compose run --rm --service-ports approov-token-binding-check zsh
93+
```
94+
95+
## Support
96+
97+
If you find any issue while following this quickstart then just open an issue on this repo with the steps to reproduce it and we will help you to solve them.

docker-compose.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: "2.3"
2+
3+
services:
4+
5+
unprotected-server:
6+
image: approov/php:8.1.4
7+
build: ./
8+
networks:
9+
- default
10+
command: sh -c "composer install && php artisan serve --port 8002 --host 0.0.0.0"
11+
ports:
12+
- ${HOST_IP:-127.0.0.1}:${HTTP_PORT:-8002}:${HTTP_PORT:-8002}
13+
volumes:
14+
- ./src/unprotected-server/hello:/home/developer/workspace
15+
16+
approov-token-check:
17+
image: approov/php:8.1.4
18+
build: ./
19+
networks:
20+
- default
21+
command: sh -c "composer install && php artisan serve --port 8002 --host 0.0.0.0"
22+
ports:
23+
- ${HOST_IP:-127.0.0.1}:${HTTP_PORT:-8002}:${HTTP_PORT:-8002}
24+
volumes:
25+
- ./src/approov-protected-server/token-check/hello:/home/developer/workspace
26+
27+
approov-token-binding-check:
28+
image: approov/php:8.1.4
29+
build: ./
30+
networks:
31+
- default
32+
command: sh -c "composer install && php artisan serve --port 8002 --host 0.0.0.0"
33+
ports:
34+
- ${HOST_IP:-127.0.0.1}:${HTTP_PORT:-8002}:${HTTP_PORT:-8002}
35+
volumes:
36+
- ./src/approov-protected-server/token-binding-check/hello:/home/developer/workspace
37+

0 commit comments

Comments
 (0)