version: "3.1"

services:
  reverse_proxy:
    build: ./reverse_proxy
    user: nginx

  database:
    build: 
       context: ./database
    image: atsea_db
    user: postgres
    environment:
      POSTGRES_USER: gordonuser
      POSTGRES_DB_PASSWORD_FILE: /run/secrets/postgres_password
      POSTGRES_DB: atsea
    ports:
      - "5432:5432" 
    networks:
      - back-tier
    secrets:
      - postgres_password

  appserver:
    build:
       context: app
       dockerfile: Dockerfile
    image: atsea_app
    user: gordon
    ports:
      - "8080:8080" 
      - "5005:5005"
    networks:
      - front-tier
      - back-tier
    secrets:
      - postgres_password

  payment_gateway:
    build:
      context: payment_gateway
    networks:
      - payment
    secrets:
      - payment_token

networks:
  front-tier:
  back-tier:
  payment:
    driver: overlay

secrets:
  postgres_password:
    file: ./devsecrets/postgres_password
  payment_token:
    file: ./devsecrets/payment_token

version: "3.1"

services:
  reverse_proxy:
    build: ./reverse_proxy
    user: nginx

  database:
    build: 
       context: ./database
    image: atsea_db
    user: postgres
    environment:
      POSTGRES_USER: gordonuser
      POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
      POSTGRES_DB: atsea
    ports:
      - "5432:5432" 
    networks:
      - back-tier
    secrets:
      - postgres_password

  appserver:
    build:
       context: app
       dockerfile: Dockerfile
    image: atsea_app
    user: gordon
    ports:
      - "8080:8080" 
      - "5005:5005"
    networks:
      - front-tier
      - back-tier
    secrets:
      - postgres_password

  payment_gateway:
    build:
      context: payment_gateway
    networks:
      - payment
    secrets:
      - payment_token

networks:
  front-tier:
  back-tier:
  payment:
    driver: overlay

secrets:
  postgres_password:
    file: ./devsecrets/postgres_password
  payment_token:
    file: ./devsecrets/payment_token

Fix password file to actually be used
Fix password file to actually be used

According to the documentation, this is [`POSTGRES_PASSWORD_FILE`](https://github.com/docker-library/docs/tree/2b3cbc311670957d144f8c7004ba04b5d563491a/postgres#docker-secrets).  Otherwise postgres will be set with no password and just allow any connection with the correct username regardless of a supplied password.  You can verify it by running postgres with the current yaml and see this in the logs:

```console
****************************************************
WARNING: No password has been set for the database.
         This will allow anyone with access to the
         Postgres port to access your database. In
         Docker's default configuration, this is
         effectively any other container on the same
         system.

         Use "-e POSTGRES_PASSWORD=password" to set
         it in "docker run".
****************************************************
```

You'll also want to update the blog post on Docker Blog that copies this part of the file: https://blog.docker.com/2017/07/securing-atsea-app-docker-secrets/.