Skip to content

Commit

Permalink
配置docker一键启动
Browse files Browse the repository at this point in the history
  • Loading branch information
bbbbbbbbbbbbba committed Sep 16, 2024
1 parent ca9d254 commit 208edee
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 55 deletions.
28 changes: 0 additions & 28 deletions .docker-compose/nginx.conf

This file was deleted.

21 changes: 10 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ ENV APP_HOME=/code/bbs-go/site
WORKDIR "$APP_HOME"

COPY ./site ./
# RUN npm install -g pnpm --registry=https://registry.npmmirror.com
# RUN pnpm install --registry=https://registry.npmmirror.com
RUN npm install -g pnpm
RUN pnpm install
RUN npm install -g pnpm --registry=https://registry.npmmirror.com
RUN pnpm install --registry=https://registry.npmmirror.com
# RUN npm install -g pnpm
# RUN pnpm install
RUN pnpm build:docker


Expand All @@ -34,10 +34,10 @@ ENV APP_HOME=/code/bbs-go/admin
WORKDIR "$APP_HOME"

COPY ./admin ./
# RUN npm install -g pnpm --registry=https://registry.npmmirror.com
# RUN pnpm install --registry=https://registry.npmmirror.com
RUN npm install -g pnpm
RUN pnpm install
RUN npm install -g pnpm --registry=https://registry.npmmirror.com
RUN pnpm install --registry=https://registry.npmmirror.com
# RUN npm install -g pnpm
# RUN pnpm install
RUN pnpm build:docker

# run
Expand All @@ -52,12 +52,11 @@ COPY --from=server_builder /code/bbs-go/server/*.yaml ./server/
COPY --from=server_builder /code/bbs-go/server/*.yml ./server/
COPY --from=site_builder /code/bbs-go/site/.output ./site/.output
COPY --from=site_builder /code/bbs-go/site/node_modules ./site/node_modules
COPY --from=admin_builder /code/bbs-go/admin/dist ./admin
COPY --from=admin_builder /code/bbs-go/admin/dist ./server/admin

COPY ./start.sh ${APP_HOME}/start.sh
RUN chmod +x ${APP_HOME}/start.sh

EXPOSE 8082
EXPOSE 3000
EXPOSE 8082 3000 80

CMD ["./start.sh"]
29 changes: 13 additions & 16 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,22 @@ services:
context: ./
volumes:
- /data/docker:/data
- bbsgo-admin:/app/bbs-go/admin # 这里定义了一个卷
environment:
BBSGO_ENV: docker
BBSGO_DB_URL: root:123456@tcp(bbs-go-mysql:3306)/bbsgo_db?charset=utf8mb4&parseTime=True&loc=Local
BBSGO_BASEURL: http://localhost
restart: on-failure


nginx:
container_name: bbs-go-nginx
image: nginx:latest
BBSGO_BASEURL:
ports:
- 80:80
volumes:
- .docker-compose/nginx.conf:/etc/nginx/conf.d/default.conf # 挂载自定义的 nginx 配置文件
- bbsgo-admin:/usr/share/nginx/html/admin # 使用同一个卷
depends_on:
- bbsgo
- 8082:8082
- 3000:3000
restart: on-failure

volumes:
bbsgo-admin: # 定义卷
# nginx:
# container_name: bbs-go-nginx
# image: nginx:latest
# ports:
# - 80:80
# volumes:
# - .docker-compose/nginx.conf:/etc/nginx/conf.d/default.conf
# depends_on:
# - bbsgo
# restart: on-failure
1 change: 1 addition & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ tags
logs/*.log
web/*
tmp/*
admin/*

internal/web*

Expand Down
2 changes: 2 additions & 0 deletions server/internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func NewServer() {
})
})

app.HandleDir("/admin", "./admin")

// api
mvc.Configure(app.Party("/api"), func(m *mvc.Application) {
m.Party("/topic").Handle(new(api.TopicController))
Expand Down
3 changes: 3 additions & 0 deletions site/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ export default defineNuxtConfig({
'/api/**': {
proxy: `${import.meta.env.SERVER_URL}/api/**`,
},
'/admin/**': {
proxy: `${import.meta.env.SERVER_URL}/admin/**`,
},
},
},

Expand Down

0 comments on commit 208edee

Please sign in to comment.