Forráskód Böngészése

Use docker image env variables for config

Andrew Swistak 6 éve
szülő
commit
863695ca7c
2 módosított fájl, 13 hozzáadás és 7 törlés
  1. 10 3
      .env.template
  2. 3 4
      docker-compose.yml

+ 10 - 3
.env.template

@@ -1,10 +1,17 @@
 PKPARSE_URL=
 
-# Password for postgres. The default password for the postgres container is
-# simply 'postgres'. Please change this to something more unique. Avoid unsafe
-# URL characters (`@`, `:`, `/`, etc)
+# Superuser for postgres. The default is simply 'postgres'. Please change this
+# to something more unique. Avoid unsafe URL characters (`@`, `:`, # `/`, etc)
+POSTGRES_USER=postgres
+
+# Password for postgres. The default is simply 'postgres'. Please change this to
+# something more unique. Avoid unsafe URL characters (`@`, `:`, # `/`, etc)
 POSTGRES_PASSWORD=postgres
 
+# Name of the database for the containers to use. The default is
+# `POSTGRES_USER`, or simply `postgres`
+POSTGRES_DB=pokemon_trade_dev
+
 # Port which Rails is exposed on
 WEB_HOST_PORT=3000
 

+ 3 - 4
docker-compose.yml

@@ -3,14 +3,12 @@ services:
   web:
     build:
       context: .
-      target: builder
-    # Even though CMD is defined in the Dockerfile, we need to provide a CMD here
-    # because we are using a compose entrypoint. See https://github.com/docker/compose/issues/3140
+      target: dev
     command: rails server -p 3000 -b 0.0.0.0
     depends_on:
       - db
     environment:
-      - DATABASE_URL=postgres://postgres:${POSTGRES_PASSWORD}@db:5432/pokemon_trade_dev
+      - DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
     ports:
       - ${WEB_HOST_PORT}:3000
     volumes:
@@ -21,6 +19,7 @@ services:
 
   db:
     environment:
+      - POSTGRES_USER
       - POSTGRES_PASSWORD
     image: postgres:11.2-alpine
     ports: