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 mkdir /work/
RUN apk update && apk upgrade && \ WORKDIR /work/
apk add --no-cache git
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################### ###########START NEW IMAGE###################
FROM alpine:3.9 as prod FROM dev as prod
COPY --from=dev /work/app /
CMD ./app 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 mkdir /work/
RUN apk update && apk upgrade && \ WORKDIR /work/
apk add --no-cache git
RUN go get github.com/sirupsen/logrus COPY ./src/requirements.txt /work/requirements.txt
RUN go get github.com/buaazp/fasthttprouter RUN pip install -r requirements.txt
RUN go get github.com/valyala/fasthttp
COPY ./src/ /work/
WORKDIR /work
COPY ./src /work/
RUN go build -o app
###########START NEW IMAGE################### ###########START NEW IMAGE###################
FROM alpine:3.9 as prod FROM python:3.7.3-alpine3.9 as prod
COPY --from=dev /work/app /
CMD ./app 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