diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 5fb5965..42ba4a3 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -28,7 +28,8 @@ RUN apt-get update && \ ARG APP_USER ARG APP_USER_ID -RUN useradd -m -s /bin/bash -u $APP_USER_ID $APP_USER && \ +RUN userdel ubuntu && \ + useradd -m -s /bin/bash -u $APP_USER_ID $APP_USER && \ mkdir -p /workspace && \ chown $APP_USER:$APP_USER -R /workspace diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 70559c2..c03b12b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,10 @@ { - "name": "Symfony RealWorld Example Dev Container", - "dockerComposeFile": [], + "name": "Symfony RealWorld Example", + "dockerComposeFile": [ + "../docker-compose.yml", + "../docker-compose.dev.yml", + "docker-compose.yml" + ], "service": "devcontainer", "workspaceFolder": "/workspace", "customizations": { diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..0218bfb --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,16 @@ +services: + devcontainer: + build: + context: . + dockerfile: .devcontainer/Dockerfile + args: + - APP_USER=${APP_USER:-app} + - APP_USER_ID=${APP_USER_ID:-1000} + environment: + - DATABASE_URL=postgresql://${APP_USER:-app}:${DB_PSWD:-!ChangeMe!}@db:5432/${DB_NAME:-app}?serverVersion=16&charset=utf8 + volumes: + - .:/workspace + command: /bin/sh -c "while sleep 1000; do :; done" + networks: + - frontend + - backend diff --git a/README.md b/README.md index b12a97b..e2a91dd 100644 --- a/README.md +++ b/README.md @@ -54,11 +54,6 @@ Make sure you have [Docker](https://docs.docker.com/get-docker/) installed. Clone the repository. -Create Docker environment file from the sample: -``` -cp env.txt .env -``` - Launch Docker services: ``` docker compose up -d diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 0e11526..3f03164 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -15,24 +15,6 @@ services: db: ports: - 5432:5432 - devcontainer: - build: - context: . - dockerfile: .devcontainer/Dockerfile - args: - - APP_USER=${APP_USER} - - APP_USER_ID=${APP_USER_ID} - environment: - - DATABASE_URL=postgresql://${APP_USER}:${DB_PSWD}@db:5432/${DB_NAME}?serverVersion=16&charset=utf8 - volumes: - - .:/workspace - ### Add various user settings - # - $HOME/.gitconfig:/home/$APP_USER/.gitconfig - # - $HOME/.ssh:/home/$APP_USER/.ssh - command: /bin/sh -c "while sleep 1000; do :; done" - networks: - - frontend - - backend proxy: volumes: - ./app/public:/var/www/html/public diff --git a/docker-compose.yml b/docker-compose.yml index b8ba57c..bc8163f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,10 +4,10 @@ services: context: ./app target: app_prod args: - - APP_USER=${APP_USER} - - APP_USER_ID=${APP_USER_ID} + - APP_USER=${APP_USER:-app} + - APP_USER_ID=${APP_USER_ID:-1000} environment: - - DATABASE_URL=postgresql://${APP_USER}:${DB_PSWD}@db:5432/${DB_NAME}?serverVersion=16&charset=utf8 + - DATABASE_URL=postgresql://${APP_USER:-app}:${DB_PSWD:-!ChangeMe!}@db:5432/${DB_NAME:-app}?serverVersion=16&charset=utf8 depends_on: - db networks: @@ -16,9 +16,9 @@ services: db: image: postgres:16-alpine environment: - - POSTGRES_DB=${DB_NAME} - - POSTGRES_PASSWORD=${DB_PSWD} - - POSTGRES_USER=${APP_USER} + - POSTGRES_DB=${DB_NAME:-app} + - POSTGRES_PASSWORD=${DB_PSWD:-!ChangeMe!} + - POSTGRES_USER=${APP_USER:-app} networks: - backend volumes: @@ -28,14 +28,14 @@ services: context: ./app target: proxy args: - - APP_USER=${APP_USER} - - APP_USER_ID=${APP_USER_ID} + - APP_USER=${APP_USER:-app} + - APP_USER_ID=${APP_USER_ID:-1000} depends_on: - app networks: - frontend ports: - - ${APP_PORT}:80 + - ${APP_PORT:-80}:80 volumes: db_data: