分类

链接

2024 年 11 月
 123
45678910
11121314151617
18192021222324
252627282930  

近期文章

热门标签

新人福利,免费薅羊毛

现在位置:    首页 > LINUX > 正文
共享办公室出租
centos安装node18
LINUX 暂无评论 阅读(5)
curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo bash -

sudo yum install -y nodejs

node --version

npm --version

 

如果装不上,直接放弃!

 

用docker运行即可:

 

dockerfile:

# 使用官方Node.js 18镜像
FROM node:18
 
# 设置工作目录
WORKDIR /app

# 暴露容器的端口号
EXPOSE 3000
 
# 运行项目
CMD ["node", "/app/server/index.mjs"]

 

docker-compose.yml:

version : '3'
services:    
  mysql:
    container_name: mysql
    image: docker.m.daocloud.io/mysql:5.7
    build:
      context: ./mysql
    ports:
      - "13306:3306"
    volumes:
      - ./mysql/conf/my.cnf:/etc/mysql/my.cnf
      - ./mysql/logs:/logs
      - ./mysql/data:/var/lib/mysql
      - ./mysql/init-sql/:/docker-entrypoint-initdb.d
    command: [
        '--character-set-server=utf8mb4',
        '--collation-server=utf8mb4_general_ci', 
        '--max_allowed_packet=128M', 
        '--innodb-buffer-pool-size=256M',
        '--default-time-zone=+08:00'
    ]
    environment:
      MYSQL_USER: 'xxx'
      MYSQL_PASSWORD: 'xxx'
      MYSQL_DATABASE:  'xxx'
      MYSQL_ROOT_PASSWORD: 'xxx'
    restart: always
    
  redis:
    image:  docker.m.daocloud.io/redis
    restart: always
    hostname: redis
    container_name: redis
    ports:
      - 16379:6379
    command: redis-server /etc/redis/redis.conf
    environment:
      TZ: Asia/Shanghai
    volumes:
      - ./redis/redis.conf:/etc/redis/redis.conf
      - ./redis/data:/data
      - ./redis/logs:/logs

  porsche-api:
    hostname: porsche-api
    container_name: porsche-api
    image: porsche-api
    build:
      context: porsche-api
      dockerfile: Dockerfile
    ports:
      - "9000:8000"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    restart: always
  bulgari-allegra-nuxt:
    hostname: bulgari-allegra-nuxt
    container_name: bulgari-allegra-nuxt
    image: node:18
    build:
      context: bulgari-allegra-nuxt
      dockerfile: Dockerfile
    volumes:
      - /root/bulgari-allegra-nuxt/:/app
    ports:
      - "3000:3000"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
    restart: always

 

============ 欢迎各位老板打赏~ ===========

本文版权归Bruce's Blog所有,转载引用请完整注明以下信息:
本文作者:Bruce
本文地址:centos安装node18 | Bruce's Blog

发表评论

留言无头像?