forked from observeinc/google-cloud-functions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (33 loc) · 1.3 KB
/
Dockerfile
File metadata and controls
46 lines (33 loc) · 1.3 KB
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
# Use a builder image for installing google cloud sdk
FROM python:3.11-slim-buster
# Accept the user ID and group ID as build arguments
ARG UID=1000
ARG GID=1000
WORKDIR /install
# Environment variable to find the google-cloud-sdk
ENV PATH=$PATH:/usr/local/bin/google-cloud-sdk/bin/
# Install Google Cloud SDK
RUN apt-get update -y && apt-get install -y curl make && \
curl https://sdk.cloud.google.com > install.sh && \
bash install.sh --disable-prompts --install-dir=/usr/local/bin && \
gcloud --version && \
rm -rf install.sh
# Create a group and user with the provided IDs, and create a home directory for the user
RUN groupadd -r gcpuser -g ${GID} && \
useradd -r -g gcpuser -u ${UID} -m -d /home/gcpuser -s /bin/bash gcpuser && \
chown -R gcpuser:gcpuser /home/gcpuser
RUN mkdir -p /home/gcpuser/.config && chmod 777 /home/gcpuser/.config
WORKDIR /src
# Copy the local src directory to the Docker image
COPY . /src
# Install Python packages
RUN pip install --no-cache-dir -r requirements.txt
# Change the ownership of the src directory to our user and group
RUN chown -R gcpuser:gcpuser /src
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Change to our non-root user and set the home directory
USER gcpuser
ENV HOME=/home/gcpuser
ENTRYPOINT ["/entrypoint.sh"]
CMD ["bash"]