Docker
Docker containers provide a consistent deployment environment and can be hosted on various platforms like Fly.io, Railway, or any container hosting service.
Creating a Dockerfile
Create a Dockerfile in your project root:
dockerfile
FROM denoland/deno:2.1.9
WORKDIR /app
# Cache dependencies
COPY deno.json deno.json
COPY deno.lock deno.lock
RUN deno install
# Copy source code
COPY . .
# The bot needs network access and environment variables
ENV SERVER_NAME=your-domain.com
# Run the bot
CMD ["deno", "run", "-A", "bot.ts"]
Deploying to Fly.io
Install the Fly.io CLI
Initialize your Fly.io app:
bashfly launch
Configure environment variables:
bashfly secrets set SERVER_NAME=your-domain.com
Deploy your app:
bashfly deploy
Deploying to Railway
Create a new project on Railway
Connect your GitHub repository
Configure environment variables in the Railway dashboard
Railway will automatically build and deploy your container