mirror of
https://github.com/DiscordFactory/website-documentation.git
synced 2026-01-26 14:50:26 +01:00
Working on docker doc
This commit is contained in:
@@ -41,15 +41,58 @@
|
|||||||
<p>Then open a terminal in the root folder of your application and run the following command :</p>
|
<p>Then open a terminal in the root folder of your application and run the following command :</p>
|
||||||
<CodeHighlight :code="startPm2" />
|
<CodeHighlight :code="startPm2" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-5">
|
||||||
|
<h2>Deploy with Docker</h2>
|
||||||
|
<p>Docker is free software for launching applications in isolated containers.</p>
|
||||||
|
<div>
|
||||||
|
<p class="mr-2">Learn more: </p>
|
||||||
|
<LinkExternal url="https://www.docker.com">
|
||||||
|
Docker Documentation
|
||||||
|
</LinkExternal>
|
||||||
|
</div>
|
||||||
|
<AlertWarn>
|
||||||
|
<template v-slot:label>
|
||||||
|
Warn
|
||||||
|
</template>
|
||||||
|
<template v-slot:message>
|
||||||
|
In the docker section, replace <br />
|
||||||
|
- <span class="font-bold">[name]</span> with the name of your bot, <br />
|
||||||
|
- <span class="font-bold">[version]</span> with the version of your bot. (You can use `latest`, `dev`... with docker) <br />
|
||||||
|
- <span class="font-bold">[env]</span> with your env file (`.env`, `environment.json` or `environment.yml`)
|
||||||
|
</template>
|
||||||
|
</AlertWarn>
|
||||||
|
<p>Create a root file named <code class="active">Dockerfile</code>.</p>
|
||||||
|
<CodeHighlight :code="Dockerfile" />
|
||||||
|
<p>Then open a terminal in the root folder of your application and run the following command :</p>
|
||||||
|
<CodeHighlight :code="buildImage" />
|
||||||
|
<p>Use docker-compose to automate the start command of your bot with the following content :</p>
|
||||||
|
<CodeHighlight :code="dockerCompose" />
|
||||||
|
<p>Finally, you can run your image inside a container with the following command :</p>
|
||||||
|
<CodeHighlight :code="startContainer" />
|
||||||
|
<AlertInfo>
|
||||||
|
<template v-slot:label>
|
||||||
|
Info
|
||||||
|
</template>
|
||||||
|
<template v-slot:message>
|
||||||
|
The option <span class="font-bold">-d</span> allows to launch the container in the background.
|
||||||
|
</template>
|
||||||
|
</AlertInfo>
|
||||||
|
<p>To stop the container, run the following command :</p>
|
||||||
|
<CodeHighlight :code="stopContainer" />
|
||||||
|
<p>To stop see the log of your discord bot, run the following command :</p>
|
||||||
|
<CodeHighlight :code="seeLogs" />
|
||||||
|
</div>
|
||||||
</Documentation>
|
</Documentation>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import Documentation from '../../../../components/Documentation.vue'
|
import Documentation from '../../../../components/Documentation.vue'
|
||||||
import CodeHighlight from '../../../../components/CodeHighlight.vue'
|
import CodeHighlight from '../../../../components/CodeHighlight.vue'
|
||||||
import Divider from '../../../../components/Divider.vue'
|
|
||||||
import LinkExternal from '../../../../components/LinkExternal.vue'
|
import LinkExternal from '../../../../components/LinkExternal.vue'
|
||||||
import AlertWarn from '../../../../components/AlertWarn.vue'
|
import AlertInfo from '../../../../components/AlertInfo.vue'
|
||||||
|
import AlertWarn from "../../../../components/AlertWarn.vue";
|
||||||
|
|
||||||
const ecosystem = `
|
const ecosystem = `
|
||||||
module.exports = {
|
module.exports = {
|
||||||
apps : [{
|
apps : [{
|
||||||
@@ -63,4 +106,46 @@ module.exports = {
|
|||||||
const startPm2 = `
|
const startPm2 = `
|
||||||
$ cd /path/to/project/folder/root
|
$ cd /path/to/project/folder/root
|
||||||
$ pm2 start`
|
$ pm2 start`
|
||||||
|
|
||||||
|
const Dockerfile = `
|
||||||
|
FROM node:16-alpine3.11
|
||||||
|
|
||||||
|
RUN mkdir -p /usr/src/[name]
|
||||||
|
|
||||||
|
WORKDIR /usr/src/[name]
|
||||||
|
|
||||||
|
COPY . /usr/src/[name]
|
||||||
|
|
||||||
|
RUN yarn build
|
||||||
|
|
||||||
|
CMD ["yarn", "start"]
|
||||||
|
`
|
||||||
|
|
||||||
|
const buildImage = `
|
||||||
|
$ cd /path/to/project/folder/root
|
||||||
|
$ docker build -t [name]:[version] .
|
||||||
|
`
|
||||||
|
|
||||||
|
const startContainer = `
|
||||||
|
$ docker-compose up -d
|
||||||
|
`
|
||||||
|
|
||||||
|
const stopContainer = `
|
||||||
|
$ docker-compose down
|
||||||
|
`
|
||||||
|
|
||||||
|
const seeLogs = `
|
||||||
|
$ docker logs [name]
|
||||||
|
`
|
||||||
|
|
||||||
|
const dockerCompose = `
|
||||||
|
version: "3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
[name]:
|
||||||
|
image: [name]:[version]
|
||||||
|
container_name: [name]
|
||||||
|
volumes:
|
||||||
|
- "/path/to/project/folder/root/[env]:/usr/src/[name]/[env]:ro"
|
||||||
|
`
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user