A while ago, I made a simple Node.JS app which periodically scans the feed of Reddit, and stores posts meeting certain criteria on certain subreddits (e.g. /r/programming) for later review.
As the app itself is a simple express.js application with a view engine, with connections to an external MongoDB database on MongoDB Atlas, I thought that it would be convenient to Dockerize the app for deployment.
While the Dockerization process was relatively simple, it wasn’t as straightforward to find the right actions to make to get Azure to pull the image successfully, which is why I decided to document this process.
Push to Gitlab
Once a Dockerfile has been created for the desired project, browse to the chosen repo and follow instructions under Packages -> Container Registry.
If two-factor-authentication is enabled, a Personal Access Token with
api scope is required.
Once the image has been pushed, it should show up once the page is refreshed.
Next, browse to Settings -> Repository.
Create a deploy token with
read_registry scope and note down the password.
Setup on Azure
Create an App Service Web App. beside Publish, select Docker Container.
Proceed to the Docker tab. Under Image Source, select Private Registry. If an app has already been created, change these settings under the ‘Containers settings’ page instead.
The server URL should be
The username/password fields should reflect the username/password of the deploy token.
The image and tag field should be something the lines of
registry.gitlab.com/<username>/<repo>:latest, the former part of which can be obtained by clicking the copy icon on the Container Registry page on Gitlab.
Finally, verify whether the actions were successful by accessing the app or by going to the Containers settings page after deployment and refreshing the logs.
Command line instructions are available here.