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

MySQL 8.0.2 offline installation and configuration method graphic tutorial

The offline installation method of MySQL_8.0.2 is...

Packetdrill's concise user guide

1. Packetdrill compilation and installation Sourc...

Docker creates MySQL explanation

1. Download MySQL Image Command: docker pull mysq...

Deep understanding of the use of ::before/:before and ::after/:after

Part 1: Basics 1. Unlike pseudo-classes such as :...

How to install grafana and add influxdb monitoring under Linux

Install grafana. The official website provides an...

How to use xshell to connect to Linux in VMware (2 methods)

【Foreword】 Recently I want to stress test ITOO...

Examples of correct judgment methods for data types in JS

Table of contents Preface Can typeof correctly de...

Vue implements login verification code

This article example shares the specific code of ...

Detailed explanation of MySQL InnoDB index extension

Index extension: InnoDB automatically extends eac...

How to view and execute historical commands in Linux

View historical commands and execute specified co...

Several methods to clear floating (recommended)

1. Add an empty element of the same type, and the...

Causes and solutions for MySQL deadlock

The database, like the operating system, is a sha...

About deploying a web project to Alibaba Cloud Server (5 steps to do it)

1. First log in to the Alibaba Cloud website to r...