Differences between revisions 1 and 2
Revision 1 as of 2020-05-07 20:29:59
Size: 639
Editor: PieterSmit
Comment:
Revision 2 as of 2020-11-15 09:02:21
Size: 1615
Editor: PieterSmit
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
 = Example Dockerfile to use as base = = Example Dockerfile to use as base =
Line 22: Line 22:


 * Dockerfile for serverless aws lambda build {{{

#PES 2020
FROM debian:buster

# Install Python3 with pip and devel
# Install GCC, Make and MySQL-devel, NodeJS, Nano, findutils, and libyaml for parsing .yml (serverless) via Python
# Clean-up after ourselves
#RUN curl --silent --location https://rpm.nodesource.com/setup_8.x | bash - && \
RUN apt-get update &&\
    apt-get upgrade -y &&\
    apt-get install -y \
        apt-utils \
        python3-pip python3-dev \
        python3-yaml \
        make \
        nodejs npm \
        vim findutils
        git && \
     apt-get clean all && rm -rf /var/cache/apt

# Install the serverless framework globally
RUN npm install -g serverless

# Install/upgrade pip, awscli, mysqlclient for both Python 2.7 and Python 3.6
RUN ls -la /usr/local/bin
RUN find / -iname "pip*"

RUN pip-3 install --no-cache-dir --upgrade pip awscli mysqlclient pyyaml
  
ENTRYPOINT ["/bin/bash"]
# "-c"]

}}}

Example Dockerfile to use as base

  • Multistage, state one "FROM base as builder" builds code/libs
    • Second stage starts over "FROM base" and copies "--from=builder" files from first container.
  • example Dockerfile

    FROM python:3.7-alpine as base
    FROM base as builder
    RUN mkdir /install
    WORKDIR /install
    COPY requirements.txt /requirements.txt
    RUN pip install --install-option="--prefix=/install" -r /requirements.txt
    
    
    FROM base
    COPY --from=builder /install /usr/local
    COPY src /app
    COPY README.md /
    WORKDIR /app
    #With entrypoint can pass commandline arguments
    ENTRYPOINT ["python" , "send-mail.py"]
  • Dockerfile for serverless aws lambda build

    #PES 2020
    FROM debian:buster
    
    # Install Python3 with pip and devel
    # Install GCC, Make and MySQL-devel, NodeJS, Nano, findutils, and libyaml for parsing .yml (serverless) via Python
    # Clean-up after ourselves
    #RUN curl --silent --location https://rpm.nodesource.com/setup_8.x | bash - && \
    RUN apt-get update &&\ 
        apt-get upgrade -y &&\
        apt-get install -y \
            apt-utils \
            python3-pip python3-dev \
            python3-yaml \
            make \
            nodejs npm \
            vim findutils 
            git && \
         apt-get clean all && rm -rf /var/cache/apt
    
    # Install the serverless framework globally
    RUN npm install -g serverless
    
    # Install/upgrade pip, awscli, mysqlclient for both Python 2.7 and Python 3.6
    RUN ls -la /usr/local/bin
    RUN find / -iname "pip*"
    
    RUN pip-3 install --no-cache-dir --upgrade pip awscli mysqlclient pyyaml
      
    ENTRYPOINT ["/bin/bash"] 
    # "-c"]

vigor: docker/Dockerfile (last edited 2020-11-15 09:02:21 by PieterSmit)