Explanation of the process of docker packaging node project

Explanation of the process of docker packaging node project

As a backend programmer, sometimes I have to tinker with frontend stuff. So, my boss asked me to package the front-end project into a docker package. Okay, let’s stop talking nonsense. To install the docker package, you must first have a dockerfile, so let's write docker first

Dockerfile

FROM daocloud.io/node:7
MAINTAINER abel.yang <[email protected]>
LABEL Description="This image is built for web"
RUN mkdir -p /opt/apps/epp
COPY . /opt/apps/epp
WORKDIR /opt/apps/epp/epp-web/server
ENV LANG C.UTF-8
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo Asia/Shanghai > /etc/timezone
EXPOSE 3001
CMD [ "npm", "start" ]

Okay, the Dockerfile is written and executes the image creation command.

myeppweb is the name of the mirror I typed

docker build -t myeppweb .
// Note. Don't forget.

start up

At this time, execute docker images to view the successfully packaged image

Execute the startup command:

docker run -d -p 3001:3001 myeppweb

analyze

Okay, let me explain the command of dockerfile

Package the image based on the image of daocloud.io/node:7

FROM daocloud.io/node:7

This is the maintainer's information.

MAINTAINER abel.yang <[email protected]>
LABEL Description="This image is built for web"

Create a folder and move all the files in the current folder into the new folder. (The files in my current folder are the front-end executable code. You can run the code by simply typing npm run start)

RUN mkdir -p /opt/apps/epp
COPY . /opt/apps/epp

Set the current path, that is, all the following commands are executed in this path

WORKDIR /opt/apps/epp/epp-web/server

Set the mirror time and time zone

ENV LANG C.UTF-8
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo Asia/Shanghai > /etc/timezone

Exposed Ports

EXPOSE 3001

Start the node

CMD [ "npm", "start" ]

Well, this article just records the packaging process.

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • Analysis of Springboot microservice packaging Docker image process
  • A brief analysis of SpringBoot packaging and uploading to docker and implementing multi-instance deployment (IDEA version)
  • Detailed explanation of how to use Docker to deploy a web project and package it into an image file
  • Using jib to package docker images
  • Detailed explanation of Docker container basic system image packaging
  • How to implement packaging in docker python
  • Detailed explanation of Docker package python commands
  • How to update, package, and upload Docker containers to Alibaba Cloud

<<:  js dynamically implements table addition and deletion operations

>>:  Vue implements login type switching

Recommend

How to deploy gitlab using Docker-compose

Docker-compose deploys gitlab 1. Install Docker I...

The perfect solution for Vue routing fallback (vue-route-manager)

Table of contents Routing Manager background gett...

Implementation of navigation bar and drop-down menu in CSS

1. CSS Navigation Bar (1) Function of the navigat...

Summary of HTML horizontal and vertical centering issues

I have encountered many centering problems recent...

How to install Tomcat-8.5.39 on centos7.6

Here is how to install Tomcat-8.5.39 on centos7.6...

Detailed explanation of incompatible changes in rendering functions in Vue3

Table of contents Rendering API changes Render fu...

Causes and solutions for MySQL too many connections error

Table of contents Brief summary At noon today, th...

Tutorial on installing Microsoft TrueType fonts on Ubuntu-based distributions

If you open some Microsoft documents with LibreOf...

Why the disk space is not released after deleting data in MySQL

Table of contents Problem Description Solution Pr...

vue-cli introduction and installation

Table of contents 1. Introduction 2. Introduction...

Detailed explanation of the use of JavaScript functions

Table of contents 1. Declare a function 2. Callin...

Introduction to the use and difference between in and exists in MySQL

First put a piece of code for(int i=0;i<1000;i...

The role of MySQL 8's new feature window functions

New features in MySQL 8.0 include: Full out-of-th...