Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 10a5587

Browse files
ajustes gerais nos scripts para rodar da raiz sem dar problemas
1 parent 3364876 commit 10a5587

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+784
-46
lines changed

examples/lambda_api/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def event_list(event_type):
292292
data = {}
293293

294294
response.set_data(data)
295-
response.set_total()
295+
response.set_total(len(data))
296296

297297
# event_tracker.track(event_hash, data)
298298
return response.get_response(status_code)

examples/lambda_api/docker/python/Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,19 @@ RUN apk add --no-cache build-base \
3232
# upgrade pip
3333
RUN pip install --upgrade pip
3434

35+
RUN rm -Rf ./vendor/*
36+
3537
# Install requirements
3638
COPY requirements.txt requirements-vendor.txt ./
3739
RUN pip install --no-cache-dir -r requirements.txt \
3840
&& pip install --no-cache-dir -r requirements-vendor.txt
3941

42+
# Flask compatibility with Python 3.8
43+
RUN pip uninstall dataclasses -y
44+
RUN rm -Rf ./vendor/dataclasses-0.8.dist-info/ ./vendor/dataclasses.py
45+
4046
# Copy project files
4147
COPY . .
4248

43-
#CMD [ "flask", "run", "--host", "0.0.0.0" ]
44-
CMD [ "python3", "server.py" ]
49+
CMD [ "flask", "run", "--host", "0.0.0.0" ]
4550

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
boto3
2-
pymysql
1+
boto3

examples/lambda_api/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ Flask
88
pyyaml
99
apispec
1010
marshmallow
11+
pymysql
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/bash
2+
# -----------------------------------------------------------------------------
3+
# Current file variables
4+
# -----------------------------------------------------------------------------
5+
debug=false
6+
parent_folder="../"
7+
current_path=$(pwd)/
8+
current_path_basename=$(basename $(pwd))
9+
current_file_full_path=$0
10+
# echo $current_filepath
11+
current_file_name=$(basename -- "$0")
12+
# echo $current_filename
13+
if [ $current_file_full_path = $current_file_name ] || [ $current_file_full_path = "./$current_file_name" ]; then
14+
current_file_full_path="./${current_file_full_path}"
15+
current_file_path="./"
16+
else
17+
current_file_path="${current_file_full_path/$current_file_name/''}"
18+
fi
19+
20+
current_file_path_basename=$(basename -- "$current_file_path")
21+
#echo "xxxxx current_file_path_basename $current_file_path_basename"
22+
23+
if [ -z "$current_file_path_basename" ] || [ $current_file_path = "./" ]; then
24+
# echo 'aq'
25+
current_parent_folder="../"
26+
else
27+
# echo 'naq'
28+
current_file_path_basename=$current_file_path_basename/
29+
current_parent_folder="${current_file_path/$current_file_path_basename/''}"
30+
fi
31+
32+
33+
if [ debug ]; then
34+
echo '----------------------------------------'
35+
echo "$0 - Script variables"
36+
echo '----------------------------------------'
37+
echo "current_path: $current_path"
38+
echo "current_path_basename: $current_path_basename"
39+
echo "current_file_full_path: $current_file_full_path"
40+
echo "current_file_name: $current_file_name"
41+
echo "current_file_path: $current_file_path"
42+
echo "current_parent_folder: $current_parent_folder"
43+
echo '----------------------------------------'
44+
fi
45+
46+
echo '----------------------------------------'
47+
echo "$0 - Booting lambda"
48+
echo '----------------------------------------'
49+
echo 'Installing dependencies...'
50+
echo "Requirements file: ${current_parent_folder}requirements.txt"
51+
if test -f ${current_parent_folder}requirements.txt; then
52+
python3 -m pip install -r ${current_parent_folder}requirements.txt -t ${current_parent_folder}vendor
53+
# cat ${current_parent_folder}requirements.txt
54+
echo "requirements..."
55+
fi
56+
57+
echo "Requirements file: ${current_parent_folder}requirements-vendor.txt"
58+
if test -f ${current_parent_folder}requirement.s-vendor.txt; then
59+
python3 -m pip install -r ${current_parent_folder}requirements-vendor.txt -t ${current_parent_folder}vendor
60+
# cat ${current_parent_folder}requirements-vendor.txt
61+
echo "requirements vendor..."
62+
fi
63+
64+
read -p "Press enter to continue..."
65+
66+
#echo 'Creating resource dependencies...'
67+
#echo "${current_parent_folder}scripts/localstack/lambda/create-function-from-s3.sh"
68+
69+
if test -f "${current_parent_folder}scripts/localstack/lambda/create-function-from-s3.sh"; then
70+
71+
if test -f ${current_parent_folder}.projectrc; then
72+
source ${current_parent_folder}.projectrc
73+
fi
74+
75+
if [ -z "$APP_LAMBDA_NAME" ]; then
76+
echo 'APP_LAMBDA_NAME not defined'
77+
exit 1
78+
else
79+
echo '----------------------------------------'
80+
echo "$0 - Creating the lambda: $APP_LAMBDA_NAME"
81+
echo '----------------------------------------'
82+
${current_parent_folder}scripts/localstack/lambda/create-function-from-s3.sh $current_filename_path $APP_LAMBDA_NAME
83+
84+
read -p "Press enter to continue..."
85+
86+
if test $APP_LAMBDA_EVENT_SOURCE = true;then
87+
echo '----------------------------------------'
88+
echo "$0 - Creating the event source: $APP_LAMBDA_NAME"
89+
echo '----------------------------------------'
90+
${current_parent_folder}scripts/localstack/lambda/create-event-source-mapping.sh $APP_LAMBDA_NAME $APP_QUEUE
91+
else
92+
echo 'There is no event source for this lambda'
93+
fi
94+
fi
95+
else
96+
echo "File not found: ${current_parent_folder}scripts/localstack/lambda/create-function-from-s3.sh"
97+
fi

examples/lambda_api/scripts/boot-lambdas.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,31 @@
1-
./scripts/localstack/sqs/create-queue.sh test-queue
1+
#!/bin/bash
2+
current_path=$(basename $(pwd))
3+
current_filename=$(basename -- "$0")
4+
current_filename_path=$0
5+
# echo $current_filename_path
6+
current_filename_path="${current_filename_path/$current_filename/''}"
7+
# echo $current_filename_path
8+
current_filename_path="${current_filename_path/scripts\//''}"
9+
# echo $current_filename_path
10+
current_filename_path_basename=$(basename -- "$current_filename_path")
11+
12+
echo "current_path: $current_path"
13+
echo "current_filename: $current_filename"
14+
echo "current_filename_path: $current_filename_path"
15+
echo "current_filename_path_basename: $current_filename_path_basename"
16+
17+
if test -f ${current_filename_path}/scripts/localstack/sqs/create-queue.sh; then
18+
19+
if test -f ${current_filename_path}.projectrc; then
20+
source ${current_filename_path}.projectrc
21+
fi
22+
23+
if [ -z "$APP_QUEUE" ]; then
24+
echo 'APP_QUEUE not defined'
25+
exit 1
26+
else
27+
echo "Creating the queue: $APP_QUEUE"
28+
${current_filename_path}/scripts/localstack/sqs/create-queue.sh $APP_QUEUE
29+
fi
30+
fi
31+
Lines changed: 79 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,80 @@
11
#!/bin/bash
2-
echo 'Validating jd installation..'
3-
/usr/bin/jq --help > /dev/null 2>&1
4-
if [ $? -ne 0 ]; then
5-
echo 'Installing'
6-
# download directly into ~/bin_compciv
7-
sudo curl http://stedolan.github.io/jq/download/linux64/jq -o /usr/bin/jq
8-
# give it executable permissions
9-
sudo chmod a+x /usr/bin/jq
10-
fi
11-
12-
echo 'Validate connection'
13-
./scripts/boot-validate-connection.sh
14-
15-
echo 'Booting db...'
16-
./scripts/boot-db.sh
17-
18-
echo 'Create the queues...'
19-
./scripts/boot-queues.sh
20-
21-
echo 'Create the lambdas...'
22-
./scripts/boot-lambdas.sh
2+
# -----------------------------------------------------------------------------
3+
# Current file variables
4+
# -----------------------------------------------------------------------------
5+
debug=false
6+
parent_folder="../"
7+
current_path=$(pwd)/
8+
current_path_basename=$(basename $(pwd))
9+
current_file_full_path=$0
10+
# echo $current_filepath
11+
current_file_name=$(basename -- "$0")
12+
# echo $current_filename
13+
if [ $current_file_full_path = $current_file_name ] || [ $current_file_full_path = "./$current_file_name" ]; then
14+
current_file_full_path="./${current_file_full_path}"
15+
current_file_path="./"
16+
else
17+
current_file_path="${current_file_full_path/$current_file_name/''}"
18+
fi
19+
if [ debug ]; then
20+
echo '----------------------------------------'
21+
echo "$0 - Script variables"
22+
echo '----------------------------------------'
23+
echo "current_path: $current_path"
24+
echo "current_path_basename: $current_path_basename"
25+
echo "current_file_full_path: $current_file_full_path"
26+
echo "current_file_name: $current_file_name"
27+
echo "current_file_path: $current_file_path"
28+
echo '----------------------------------------'
29+
fi
30+
31+
32+
echo '----------------------------------------'
33+
echo "$0 - jq check"
34+
echo '----------------------------------------'
35+
echo 'Validating jq installation...'
36+
/usr/bin/jq --version > /dev/null 2>&1
37+
if [ $? -ne 0 ]; then
38+
echo 'Installing jq...'
39+
# download directly into ~/bin_compciv
40+
sudo curl http://stedolan.github.io/jq/download/linux64/jq -o /usr/bin/jq
41+
# give it executable permissions
42+
sudo chmod a+x /usr/bin/jq
43+
else
44+
echo 'jq installed...'
45+
fi
46+
47+
read -p "Press enter to continue..."
48+
49+
echo '----------------------------------------'
50+
echo "$0 - Localstack connection check"
51+
echo '----------------------------------------'
52+
# valida se o Localstack está rodando
53+
if test -f ${current_file_path}boot-validate-connection.sh; then
54+
echo 'Validate connection...'
55+
${current_file_path}boot-validate-connection.sh
56+
else
57+
echo 'There is no connection check file'
58+
fi
59+
60+
read -p "Press enter to continue..."
61+
62+
echo '----------------------------------------'
63+
echo "$0 - Queues boot"
64+
echo '----------------------------------------'
65+
if test -f ${current_file_path}boot-queues.sh; then
66+
${current_file_path}boot-queues.sh
67+
else
68+
echo 'There is no queues to be booted'
69+
fi
70+
71+
read -p "Press enter to continue..."
72+
73+
echo '----------------------------------------'
74+
echo "$0 - Lambda boot"
75+
echo '----------------------------------------'
76+
if test -f ${current_file_path}boot-lambda.sh; then
77+
${current_file_path}boot-lambda.sh
78+
else
79+
echo 'There is no lambda to be booted'
80+
fi

examples/lambda_api/scripts/docker/create-network.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
if test -f .projectrc; then
22
source .projectrc
3-
elif test -f ./bin/.projectrc; then
4-
source ./bin/.projectrc
3+
elif test -f ./scripts/.projectrc; then
4+
source ./scripts/.projectrc
55
fi
66

77
if [ -z "$NETWORK_NAME" ]; then

examples/lambda_sqs/scripts/localstack/lambda/create-event-source-mapping.sh renamed to examples/lambda_api/scripts/localstack/lambda/create-event-source-mapping.sh

File renamed without changes.

0 commit comments

Comments
 (0)