Fixed wrong dockerfile for nodejs and python

docker-dev-guide_3-multistage
jason.zhu 2021-02-08 15:04:13 +11:00
parent 7e9b19b3e4
commit 6c3c33d3ef
2 changed files with 27 additions and 26 deletions

View File

@ -1,18 +1,16 @@
FROM golang:1.12.5-alpine3.9 as dev
FROM node:12.4.0-alpine as dev
# installing git
RUN apk update && apk upgrade && \
apk add --no-cache git
RUN mkdir /work/
WORKDIR /work/
COPY ./src/package.json /work/package.json
RUN npm install
COPY ./src/ /work/
RUN go get github.com/sirupsen/logrus
RUN go get github.com/buaazp/fasthttprouter
RUN go get github.com/valyala/fasthttp
WORKDIR /work
COPY ./src /work/
RUN go build -o app
###########START NEW IMAGE###################
FROM alpine:3.9 as prod
COPY --from=dev /work/app /
CMD ./app
FROM dev as prod
CMD node .

View File

@ -1,18 +1,21 @@
FROM golang:1.12.5-alpine3.9 as dev
FROM python:3.7.3-alpine3.9 as dev
# installing git
RUN apk update && apk upgrade && \
apk add --no-cache git
RUN mkdir /work/
WORKDIR /work/
RUN go get github.com/sirupsen/logrus
RUN go get github.com/buaazp/fasthttprouter
RUN go get github.com/valyala/fasthttp
COPY ./src/requirements.txt /work/requirements.txt
RUN pip install -r requirements.txt
COPY ./src/ /work/
WORKDIR /work
COPY ./src /work/
RUN go build -o app
###########START NEW IMAGE###################
FROM alpine:3.9 as prod
COPY --from=dev /work/app /
CMD ./app
FROM python:3.7.3-alpine3.9 as prod
RUN mkdir /app/
WORKDIR /app/
COPY --from=dev /work/ /app/
RUN pip install -r requirements.txt
ENV FLASK_APP=server.py
CMD flask run -h 0.0.0 -p 5000