Skip to content

Commit

Permalink
Devcontainer refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
igoryok-zp committed Sep 2, 2024
1 parent 7d4f6f9 commit 5d0928c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 35 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
16 changes: 16 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 0 additions & 18 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 5d0928c

Please sign in to comment.