docker 构建系统运行环境

 


# 使用docker
```
docker build -d sspm:2.0
docker run -d -p 8080:8080 --name sspm-zzpt-v1 sspm:2.0
```
> 版本1
FROM debian:buster-slim
ENV MONO_VERSION 6.12.0.182
RUN apt-get update \
  && apt-get install -y --no-install-recommends gnupg dirmngr ca-certificates \
  && rm -rf /var/lib/apt/lists/* \
  && export GNUPGHOME="$(mktemp -d)" \
  && gpg --batch --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF \
  && gpg --batch --export --armor 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF > /etc/apt/trusted.gpg.d/mono.gpg.asc \
  && gpgconf --kill all \
  && rm -rf "$GNUPGHOME" \
  && apt-key list | grep Xamarin \
  && apt-get purge -y --auto-remove gnupg dirmngr

RUN echo "deb https://download.mono-project.com/repo/debian stable-buster/snapshots/$MONO_VERSION main" > /etc/apt/sources.list.d/mono-official-stable.list \
  && apt-get update \
  && apt-get install -y mono-runtime \
  && rm -rf /var/lib/apt/lists/* /tmp/*
RUN apt-get update \
  && apt-get install -y binutils curl mono-devel ca-certificates-mono fsharp mono-vbnc nuget referenceassemblies-pcl \
  && rm -rf /var/lib/apt/lists/* /tmp/*
RUN mkdir -p /opt/sspm/nodejs
RUN mkdir -p /opt/ssfles
WORKDIR /opt/sspm/nodejs
COPY dockerLibs/node-v18.17.0-linux-x64.tar.gz /opt/sspm/nodejs/node-v18.17.0-linux-x64.tar.gz
RUN tar -zxvf node-v18.17.0-linux-x64.tar.gz
RUN rm node-v18.17.0-linux-x64.tar.gz
RUN mv node-v18.17.0-linux-x64  nodejs
RUN ln -s  /opt/sspm/nodejs/nodejs/bin/node  /usr/bin
RUN ln -s  /opt/sspm/nodejs/nodejs/bin/npm /usr/bin
WORKDIR /opt/sspm
COPY package.json /opt/sspm/package.json
RUN npm i
COPY src /opt/sspm/src
COPY SSDocService /opt/sspm/SSDocService
COPY www /opt/sspm/www
COPY production.js /opt/sspm/production.js
COPY dev-shr.js /opt/sspm/dev-shr.js
RUN cp /opt/sspm/SSDocService/fonts/* /usr/share/fonts/truetype/
ENV DOCKER=true
EXPOSE 8080
CMD [ "node", "dev-shr.js" ]

  

> 版本2

FROM debian:buster-slim
ENV MONO_VERSION 6.12.0.182
RUN apt-get update \
  && apt-get install -y --no-install-recommends gnupg dirmngr ca-certificates \
  && rm -rf /var/lib/apt/lists/* \
  && export GNUPGHOME="$(mktemp -d)" \
  && gpg --batch --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF \
  && gpg --batch --export --armor 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF > /etc/apt/trusted.gpg.d/mono.gpg.asc \
  && gpgconf --kill all \
  && rm -rf "$GNUPGHOME" \
  && apt-key list | grep Xamarin \
  && apt-get purge -y --auto-remove gnupg dirmngr

RUN echo "deb https://download.mono-project.com/repo/debian stable-buster/snapshots/$MONO_VERSION main" > /etc/apt/sources.list.d/mono-official-stable.list \
  && apt-get update \
  && apt-get install -y mono-runtime \
  && rm -rf /var/lib/apt/lists/* /tmp/*
RUN apt-get update \
  && apt-get install -y binutils curl mono-devel ca-certificates-mono fsharp mono-vbnc nuget referenceassemblies-pcl \
  && rm -rf /var/lib/apt/lists/* /tmp/*
RUN mkdir -p /opt/nodejs
RUN mkdir -p /opt/ssfiles
RUN mkdir -p /opt/sspm
WORKDIR /opt/nodejs
COPY dockerLibs/node-v18.17.0-linux-x64.tar.gz /opt/nodejs/node-v18.17.0-linux-x64.tar.gz
RUN tar -zxvf node-v18.17.0-linux-x64.tar.gz
RUN rm node-v18.17.0-linux-x64.tar.gz
RUN mv node-v18.17.0-linux-x64  nodejs
RUN ln -s  /opt/nodejs/nodejs/bin/node  /usr/bin
RUN ln -s  /opt/nodejs/nodejs/bin/npm /usr/bin
WORKDIR /opt/sspm
COPY package.json /opt/sspm/package.json
RUN npm i
COPY src /opt/sspm/src
COPY SSDocService /opt/sspm/SSDocService
COPY www /opt/sspm/www
COPY production.js /opt/sspm/production.js
COPY dev-shr.js /opt/sspm/dev-shr.js
RUN cp /opt/sspm/SSDocService/fonts/* /usr/share/fonts/truetype/
ENV DOCKER=true
EXPOSE 8080
CMD [ "node", "dev-shr.js" ]

  

 
 
> 版本3
FROM mono
RUN mkdir -p /opt/nodejs
RUN mkdir -p /opt/ssfiles
RUN mkdir -p /opt/sspm
WORKDIR /opt/nodejs
COPY dockerLibs/node-v18.17.0-linux-x64.tar.gz /opt/nodejs/node-v18.17.0-linux-x64.tar.gz
RUN tar -zxvf node-v18.17.0-linux-x64.tar.gz
RUN rm node-v18.17.0-linux-x64.tar.gz
RUN mv node-v18.17.0-linux-x64  nodejs
RUN ln -s  /opt/nodejs/nodejs/bin/node  /usr/bin
RUN ln -s  /opt/nodejs/nodejs/bin/npm /usr/bin
WORKDIR /opt/sspm
COPY package.json /opt/sspm/package.json
RUN npm i
COPY src /opt/sspm/src
COPY SSDocService /opt/sspm/SSDocService
COPY www /opt/sspm/www
COPY production.js /opt/sspm/production.js
COPY dev-shr.js /opt/sspm/dev-shr.js
RUN cp /opt/sspm/SSDocService/fonts/* /usr/share/fonts/truetype/
ENV DOCKER=true
EXPOSE 8080
CMD [ "node", "dev-shr.js" ]

  

> 版本4
最终版
FROM mono
RUN mkdir -p /opt/nodejs \
    && mkdir -p /opt/ssfiles \
    && mkdir -p /opt/sspm
WORKDIR /opt/nodejs
COPY dockerLibs/node-v18.17.0-linux-x64.tar.gz /opt/nodejs/node-v18.17.0-linux-x64.tar.gz
RUN tar -zxvf node-v18.17.0-linux-x64.tar.gz \
        &&  rm node-v18.17.0-linux-x64.tar.gz \
        && mv node-v18.17.0-linux-x64  nodejs \
        && ln -s  /opt/nodejs/nodejs/bin/node  /usr/bin \
        && ln -s  /opt/nodejs/nodejs/bin/npm /usr/bin
WORKDIR /opt/sspm
COPY SSDocService/fonts/* /usr/share/fonts/truetype/
ENV DOCKER=true
EXPOSE 8080
CMD [ "node", "production.js" ]

  

 
 
 
 
 
  109  sudo docker images
  110  sudo docker run -d -p 80:8080 -v /home/ssdt/Desktop/code/files:/opt/ssfiles -v /home/ssdt/Desktop/code/app:/opt/sspm --name wuxi-sspm-80 sspm-mono
  114  sudo docker ps
  116  sudo docker restart 99

  

posted @ 2023-07-25 16:47  巨兽~墨菲特  阅读(18)  评论(0编辑  收藏  举报