Guide to Dockerizing and Deploying:
1. Build the Project
Start by building the project locally. Use the command:
npm run build
2. Update the Dockerfile
Open the Dockerfile
and temporarily comment out the lines where environment variables (export
commands) are defined. This is just for the local setup.
3. Update the docker-compose.yml
Next, go to your docker-compose.yml
file and do the same — comment out any lines referencing environment variables.
4. Create an .env.production
File
Now, create a new file called .env.production
in the project root. Add the following variables with the appropriate values:
NEXT_PUBLIC_PUSHER_KEY=your_pusher_key
PUSHER_SECRET=your_pusher_secret
NEXT_PUBLIC_PUSHER_CLUSTER=your_pusher_cluster
PUSHER_APP_ID=your_pusher_app_id
SUPABASE_URL_LC_CHATBOT=your_supabase_url
SUPABASE_API_KEY=your_supabase_api_key
5. Build the Docker Image
Run the following command to build the Docker image:
docker-compose build
6. Troubleshooting Errors
If the build process fails, check the logs and fix any issues before proceeding.
7. Configure GitHub Secrets
To enable deployment with GitHub Actions, set up the required environment variables in your repository settings:
- Go to Settings → Secrets and Variables → Actions.
- Add these secrets:
AZUREAPPSERVICE_PUBLISHPROFILE=your_azure_publish_profile
NEXT_PUBLIC_PUSHER_KEY=your_pusher_key
PUSHER_SECRET=your_pusher_secret
NEXT_PUBLIC_PUSHER_CLUSTER=your_pusher_cluster
PUSHER_APP_ID=your_pusher_app_id
SUPABASE_URL_LC_CHATBOT=your_supabase_url
SUPABASE_API_KEY=your_supabase_api_key
AZURE_CONTAINER_PASSWORD=your_container_password
AZURE_CONTAINER_USERNAME=your_container_username
8. Undo Temporary Changes
Before committing your changes:
- Undo the comments in the
Dockerfile
anddocker-compose.yml
so that the build-time variables are used as intended.
9. Finalize and Push the Code
Once everything is ready:
- Commit the changes:
git commit -m "Set up Docker and GitHub Actions for Azure deployment"
- Push the code to the main branch:
git push origin main
Top comments (0)