generated from snek-functions/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
71 lines (58 loc) · 2.53 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
FROM node:18.8.0-slim
LABEL description="This container serves as an entry point for our future Snek Function projects."
LABEL org.opencontainers.image.source="https://github.com/snek-functions/authentication"
LABEL maintainer="[email protected]"
ENV LAMBDA_TASK_ROOT=/var/task \
SNEK_FUNCTIONS_BUILD_DIR=/tmp/snek-functions \
HOME=/var/task
WORKDIR ${LAMBDA_TASK_ROOT}
COPY --from=amazon/aws-lambda-nodejs:latest /usr/local/bin/aws-lambda-rie /usr/local/bin/aws-lambda-rie
COPY --from=amazon/aws-lambda-nodejs:latest /var/runtime /var/runtime
COPY --from=amazon/aws-lambda-nodejs:latest /var/lang /var/lang
COPY --from=amazon/aws-lambda-nodejs:latest lambda-entrypoint.sh .
COPY --from=amazon/aws-lambda-nodejs:latest /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt
# Override /bin/sh because some scripts are only compatible with the amazon version
COPY --from=amazon/aws-lambda-nodejs:latest /bin/sh /bin/sh
# Add static files from . to task root
COPY package.json entrypoint.sh ${LAMBDA_TASK_ROOT}/
# Copy all files form the . to the build dir
COPY ./ ${SNEK_FUNCTIONS_BUILD_DIR}/
RUN chmod +x entrypoint.sh
WORKDIR ${SNEK_FUNCTIONS_BUILD_DIR}
# Update, install and cleaning:
RUN set -ex \
&& BUILD_DEPS=" \
build-essential \
python3-dev \
python3-pip \
python3-setuptools \
" \
&& apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \
#&& ln -s /usr/local/bin/node /var/lang/bin/node \
&& npm install \
&& npx snek-functions build --functions-path . \
# Copy the built functions to the lambda function
&& rm -rf venv \
&& mkdir -p venv/bin \
&& ln -s $(which python3) venv/bin/python \
&& venv/bin/python -m pip install -r requirements.txt \
&& venv/bin/python setup_duckdb.py \
&& cp -r dist node_modules venv ${LAMBDA_TASK_ROOT} \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \
&& rm -rf /var/lib/apt/lists
# Install packages needed to run your application (not build deps):
# We need to recreate the /usr/share/man/man{1..8} directories first because
# they were clobbered by a parent image.
RUN set -ex \
&& RUN_DEPS=" \
python3 \
" \
&& seq 1 8 | xargs -I{} mkdir -p /usr/share/man/man{} \
&& apt-get update && apt-get install -y --no-install-recommends $RUN_DEPS \
&& rm -rf /var/lib/apt/lists/*
WORKDIR ${LAMBDA_TASK_ROOT}
ENTRYPOINT [ "./entrypoint.sh" ]
# Start in serverless mode
#CMD [ "app.handler" ]
# SPDX-License-Identifier: (EUPL-1.2)
# Copyright © 2022 snek.at