Last active
February 1, 2021 03:30
-
-
Save padcom/57ab8c3c36605c8c4979ca2a7f521ce9 to your computer and use it in GitHub Desktop.
Creating even smaller docker images with web applications
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules | |
dist | |
.git |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
docker build -t my-app . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node as build | |
WORKDIR /app | |
COPY package*.json ./ | |
RUN npm install | |
COPY . . | |
RUN npm run build | |
FROM alpine as runtime | |
RUN apk add --no-cache tini busybox-extras | |
WORKDIR /var/www/html | |
ENTRYPOINT [ "/sbin/tini", "-g", "--" ] | |
CMD ["httpd", "-v", "-f", "-p", "8000" ] | |
EXPOSE 8000 | |
FROM runtime | |
COPY --from=build /app/dist/ /var/www/html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
docker run -it --rm --name=my-app -p 8000:8000 my-app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment