Never deliver something for production web with a non 80 port

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the web-development category.

Last Updated: 2024-04-25

I first prepared a Dockerfile for internal use by our developers (therefore it needed a non-80 port so as not to conflict with their normal web browsing ability). This Dockerfile mapped port 7777 on the host machine to 80 in the Docker container:

services:
  wordpress:
    build:
    tty: true
    ports:
      - "7777:80"

Then I was asked to prepare it for deploying. This did not work because port 80 was not listening, as is expected with web.

I should have had defaulted to port 80 to keep this flow working (or at least created an ENV variable)

services:
  wordpress:
    build:
    tty: true
    ports:
      # This defaults to port 80, unless a port is passed into the env file.
      - "${WEB_PORT-80}:80"

Lesson

Never deliver any web-service for production with ports other than 80