Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any reason to not provide a docker image or a Dockerfile? #228

Open
ryukinix opened this issue Feb 13, 2024 · 1 comment
Open

Any reason to not provide a docker image or a Dockerfile? #228

ryukinix opened this issue Feb 13, 2024 · 1 comment

Comments

@ryukinix
Copy link

5 years ago I used this: https://hub.docker.com/r/mcgriddle/hack-chat

But is not working anymore. Any tips? For sure I can write a dockerfile for me, but I'd like to see if there is any reason to not provide a official one.

@ryukinix ryukinix changed the title Any reason to not provide a docker container? Any reason to not provide a docker image or a Dockerfile? Feb 13, 2024
@wwxiaoqi
Copy link

wwxiaoqi commented Jun 21, 2024

你只需要在根目录下创建以下文件:
You just need to create the following files in the root directory:

.dockerignore

.git
.github
test
documentation

Dockerfile

FROM node:18-bullseye-slim AS build
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN npm install --quiet

FROM node:18
COPY --from=build /usr/src/app /usr/src/app
RUN npm install pm2 -g --quiet
WORKDIR /usr/src/app

## dependencies hackchat-server
## https://github.com/npm/npm/issues/13306
## Replace renameSync with FS's moveSync to resolve the following error message
## Error: EXDEV: cross-device link not permitted, rename '/usr/src/app/commands/' -> '/usr/src/app/commands.z9kcbo'
RUN npm install fs-extra && sed -i -e "s/renameSync/moveSync/g" /usr/src/app/node_modules/hackchat-server/src/serverLib/ImportsManager.js

EXPOSE 6060 3000
CMD ["pm2-runtime", "start", "pm2.config.cjs", "--node-args='-r esm'", "--name", "hackchat"]

接着使用 docker compose 的方式运行它。
It is then run as Docker compose.

docker-compose.yml

version: "3.7"

services:
  hack-chat:
    container_name: hack-chat
    build: 
      context: .
      dockerfile: Dockerfile
    restart: on-failure

值得一提的是,在运行 docker compose 之前你需要先使用 npm run config 来生成 session.key、salt.key 文件。
It is worth mentioning that before you can run docker compose you need to use NPM run config to generate session.key、salt.key file.

正常运行后,你需要将 6060 端口用于 ws wss,3000 端口用于 web,这一步你可以看 jheretic/docker-hack-chat,里面介绍的非常详细。
Once it's up and running, you'll need to use port 6060 for WS WSS and port 3000 for the web. For this step, see jheretic/docker-hack-chat, Very detailed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants