mirror of
https://github.com/maputnik/editor.git
synced 2025-12-06 06:10:00 +00:00
Optimize docker image
* Use 2 stage docker building to produce a tiny python3-slim based docker image with just the compilation results.
This commit is contained in:
35
Dockerfile
35
Dockerfile
@@ -1,21 +1,22 @@
|
||||
FROM node:10-slim
|
||||
FROM node:10 as builder
|
||||
WORKDIR /maputnik
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
git \
|
||||
python \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
# Only copy package.json to prevent npm install from running on every build
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm install
|
||||
|
||||
EXPOSE 8888
|
||||
|
||||
ENV HOME /maputnik
|
||||
RUN mkdir ${HOME}
|
||||
|
||||
COPY . ${HOME}/
|
||||
|
||||
WORKDIR ${HOME}
|
||||
|
||||
RUN npm install -d
|
||||
# Build maputnik
|
||||
# TODO: we should also do a npm run test here (needs more dependencies)
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
WORKDIR ${HOME}/build/build
|
||||
CMD python -m SimpleHTTPServer 8888
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# Create a clean python-based image with just the build results
|
||||
FROM python:3-slim
|
||||
WORKDIR /maputnik
|
||||
|
||||
COPY --from=builder /maputnik/build/build .
|
||||
|
||||
EXPOSE 8888
|
||||
CMD python -m http.server 8888
|
||||
|
||||
Reference in New Issue
Block a user