在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):mhart/alpine-node开源软件地址(OpenSource Url):https://github.com/mhart/alpine-node开源编程语言(OpenSource Language):Dockerfile 92.2%开源软件介绍(OpenSource Introduction):Minimal Node.js Docker ImagesVersions v16.4.2, v14.17.3, v12.22.3, v10.24.1, v8.17.0, v6.17.1, v4.9.1, v0.12.18 and v0.10.48 – built on Alpine Linux. All versions use the one mhart/alpine-node repository,
but each version aligns with the following tags (ie,
Examples$ docker run --rm mhart/alpine-node:14 node --version
v14.17.3
$ docker run --rm mhart/alpine-node:12 node --version
v12.22.3
$ docker run --rm mhart/alpine-node:14 npm --version
6.14.13
$ docker run --rm mhart/alpine-node:14 yarn --version
1.22.10
$ docker run --rm mhart/alpine-node:slim-14 node --version
v14.17.3
$ docker run --rm mhart/alpine-node:slim-12 node --version
v12.22.3 Example Dockerfile for your own Node.js projectIf you're doing your For the smallest builds, use a multi-stage build – where you install your modules using the full install image, but then create your app using the slim image – this can reduce the size of your final image by ~35MB or so. # This stage installs our modules
FROM mhart/alpine-node:12
WORKDIR /app
COPY package.json package-lock.json ./
# If you have native dependencies, you'll need extra tools
# RUN apk add --no-cache make gcc g++ python3
RUN npm ci --prod
# Then we copy over the modules from above onto a `slim` image
FROM mhart/alpine-node:slim-12
# If possible, run your container using `docker run --init`
# Otherwise, you can use `tini`:
# RUN apk add --no-cache tini
# ENTRYPOINT ["/sbin/tini", "--"]
WORKDIR /app
COPY --from=0 /app .
COPY . .
CMD ["node", "index.js"] If you can't do multi-stage builds, then you can just do everything on a "full install" image: FROM mhart/alpine-node:12
# If possible, run your container using `docker run --init`
# Otherwise, you can use `tini`:
# RUN apk add --no-cache tini
# ENTRYPOINT ["/sbin/tini", "--"]
WORKDIR /app
COPY . .
# If you have native dependencies, you'll need extra tools
# RUN apk add --no-cache make gcc g++ python3
RUN npm ci --prod
CMD ["node", "index.js"] CaveatsAs Alpine Linux uses musl, you may run into some issues with environments expecting glibc-like behavior – especially if you try to use binaries compiled with glibc. You should recompile these binaries to use musl (compiling on Alpine is probably the easiest way to do this). If you get an error similar to Inspired by:
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论