-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
2,105 additions
and
1,420 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,33 @@ | ||
|
||
FROM node:lts-alpine | ||
COPY . /src | ||
RUN apk update && apk add bash && \ | ||
cd /src; yarn install && \ | ||
# Time zone option, if you live in China pleace set it to Asia/Shanghai | ||
ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime | ||
|
||
EXPOSE 3000 | ||
CMD node /src/bin/www | ||
|
||
# 设置工作目录 | ||
WORKDIR /app | ||
|
||
# 设置时区 | ||
ENV TZ=Europe/Paris | ||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \ | ||
echo $TZ > /etc/timezone | ||
|
||
# 安装基础工具、pnpm 和 docker | ||
RUN apk add --no-cache bash tzdata docker-cli && \ | ||
corepack enable && \ | ||
corepack prepare pnpm@latest --activate | ||
|
||
# 复制 package.json 和 pnpm-lock.yaml (如果存在) | ||
COPY package.json pnpm-lock.yaml* ./ | ||
|
||
# 设置 pnpm store 目录并安装依赖 | ||
RUN pnpm config set store-dir /root/.local/share/pnpm/store && \ | ||
pnpm install --frozen-lockfile | ||
|
||
# 复制源代码 | ||
COPY . . | ||
|
||
# 暴露端口 | ||
EXPOSE 3000 | ||
|
||
# 使用 root 用户运行以确保 docker.sock 访问权限 | ||
USER root | ||
|
||
# 启动应用 | ||
CMD ["node", "bin/www"] |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
echo "🔨 Building Docker image..." | ||
docker build -t easy-docker-web . | ||
|
||
echo "🚀 Starting container..." | ||
docker run -d \ | ||
--name easy-docker-web \ | ||
-p 3000:3000 \ | ||
-v /var/run/docker.sock:/var/run/docker.sock \ | ||
easy-docker-web | ||
|
||
echo "✅ Container started! Access the application at http://localhost:3000" |
This file contains 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
Oops, something went wrong.