Skip to content

Commit baf25d4

Browse files
committed
feat: refactor to sfi
1 parent cfb7cb3 commit baf25d4

17 files changed

+178
-280
lines changed

.sf/sfi.module.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile

+39-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ LABEL org.opencontainers.image.source="https://github.com/snek-functions/email"
55
LABEL maintainer="[email protected]"
66

77
ENV LAMBDA_TASK_ROOT=/var/task \
8-
SNEK_FUNCTIONS_BUILD_DIR=/tmp/snek-functions
8+
SNEK_FUNCTIONS_BUILD_DIR=/tmp/snek-functions \
9+
HOME=/var/task
910

1011
WORKDIR ${LAMBDA_TASK_ROOT}
1112

@@ -26,14 +27,47 @@ RUN chmod +x entrypoint.sh
2627

2728
WORKDIR ${SNEK_FUNCTIONS_BUILD_DIR}
2829

29-
RUN ln -s /usr/local/bin/node /var/lang/bin/node ;\
30-
npm install ;\
31-
npx snek-functions build --functions-path . ;\
30+
# Update, install and cleaning:
31+
RUN set -ex \
32+
&& BUILD_DEPS=" \
33+
build-essential \
34+
python3-dev \
35+
python3-pip \
36+
python3-setuptools \
37+
" \
38+
&& apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \
39+
#&& ln -s /usr/local/bin/node /var/lang/bin/node \
40+
&& npm install \
41+
&& npx sf build \
3242
# Copy the built functions to the lambda function
33-
cp -r dist node_modules ${LAMBDA_TASK_ROOT}
43+
&& rm -rf venv \
44+
&& mkdir -p venv/bin \
45+
&& ln -s $(which python3) venv/bin/python \
46+
&& venv/bin/python -m pip install -U pip \
47+
&& venv/bin/python -m pip install -r requirements.txt \
48+
&& venv/bin/python setup_duckdb.py \
49+
&& find src -mindepth 1 -maxdepth 1 -not -name internal -exec rm -rf {} + \
50+
&& mv .sf src node_modules venv ${LAMBDA_TASK_ROOT} \
51+
&& rm -r ${SNEK_FUNCTIONS_BUILD_DIR}/* \
52+
&& mkdir -p ${LAMBDA_TASK_ROOT}/data \
53+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \
54+
&& rm -rf /var/lib/apt/lists
55+
56+
# Install packages needed to run your application (not build deps):
57+
# We need to recreate the /usr/share/man/man{1..8} directories first because
58+
# they were clobbered by a parent image.
59+
RUN set -ex \
60+
&& RUN_DEPS=" \
61+
python3 \
62+
" \
63+
&& seq 1 8 | xargs -I{} mkdir -p /usr/share/man/man{} \
64+
&& apt-get update && apt-get install -y --no-install-recommends $RUN_DEPS \
65+
&& rm -rf /var/lib/apt/lists/*
3466

3567
WORKDIR ${LAMBDA_TASK_ROOT}
3668

69+
EXPOSE 3000
70+
3771
ENTRYPOINT [ "./entrypoint.sh" ]
3872

3973
# Start in serverless mode

entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
if [ $# -ne 1 ]; then
44
echo "Start in continuous mode" 1>&2
5-
exec yarn snek-functions server -f $LAMBDA_TASK_ROOT/dist
5+
exec yarn sf-server
66
fi
77
export _HANDLER="$1"
88

package.json

+13-9
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
"path": "git-cz"
1616
}
1717
},
18-
"dependencies": {
19-
"@snek-at/functions": "*",
20-
"nodemailer": "^6.7.8",
21-
"nodemailer-plugin-inline-base64": "^2.1.1"
22-
},
2318
"devDependencies": {
2419
"@types/nodemailer": "^6.4.6",
2520
"commitizen": "^4.2.5",
@@ -31,9 +26,18 @@
3126
},
3227
"scripts": {
3328
"build": "sf build -f . --declaration",
34-
"start": "sf build -f . && IS_OFFLINE=true nodemon --watch dist --exec sls offline --httpPort 4040 --lambdaPort 4042",
35-
"deploy": "sls deploy",
36-
"postinstall": "sf install"
29+
"start": "sf build -f . && IS_OFFLINE=true nodemon --watch dist --exec sls offline --httpPort 4050 --lambdaPort 4052",
30+
"develop": "sf develop --port 4020",
31+
"deploy": "sls deploy"
3732
},
38-
"sfDependencies": {}
33+
"sfDependencies": {},
34+
"dependencies": {
35+
"@prisma/client": "^4.10.1",
36+
"@snek-at/function": "0.0.19",
37+
"@snek-at/function-builder": "0.0.19",
38+
"@snek-at/function-cli": "0.0.7",
39+
"@snek-at/function-server": "0.0.10",
40+
"nodemailer": "^6.7.8",
41+
"nodemailer-plugin-inline-base64": "^2.1.1"
42+
}
3943
}

src/app.ts

-10
This file was deleted.
File renamed without changes.

src/factory.ts

-14
This file was deleted.

src/index.ts

-8
This file was deleted.

src/send.ts

-40
This file was deleted.

src/send2fa.ts

-47
This file was deleted.

src/sendDeleteUser.ts

-47
This file was deleted.

src/sendResetPassword.ts

-47
This file was deleted.

src/sendUserInformation.ts

-52
This file was deleted.

0 commit comments

Comments
 (0)