Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 29-build-docker-images
Browse files Browse the repository at this point in the history
  • Loading branch information
codeofmochi committed Aug 10, 2023
2 parents 4661bb8 + 6db75ca commit 83b787c
Show file tree
Hide file tree
Showing 43 changed files with 957 additions and 522 deletions.
29 changes: 26 additions & 3 deletions .devcontainer/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ services:
# Custom strapi service
strapi:
# Build the strapi service from its folder
container_name: clic-strapi
build:
# Build context, relative to the current file
context: ../strapi/.devcontainer
Expand All @@ -27,14 +28,12 @@ services:
- type: bind
source: ../strapi
target: /app
ports:
# Expose strapi to port 8001
- "8001:8001"
depends_on:
- strapi-postgres

# Database service for strapi
strapi-postgres:
container_name: clic-postgres
image: postgres
environment:
POSTGRES_DB: strapi_data
Expand All @@ -43,6 +42,30 @@ services:
volumes:
- "strapi-data:/var/lib/postgresql/data"

app:
# Build the app service from its folder
build:
# Build context, relative to the current file
context: ../app/.devcontainer
# Path to Dockerfile, relative to context
dockerfile: Dockerfile
args:
VARIANT: ${VARIANT:-18-bullseye}
environment:
NODE_ENV: development
volumes:
# Bind-mount the app project folder into the container
- type: bind
source: ../app
target: /app

caddy:
image: caddy
volumes:
- "../caddy/Caddyfile.dev:/etc/caddy/Caddyfile"
ports:
- "80:80"

volumes:
# Persist strapi database
strapi-data:
44 changes: 43 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,47 @@
"color": "white",
"backgroundColor": "orange"
},
"todohighlight.keywordsPattern": "(todo|TODO|fixme|FIXME)(:?)"
"todohighlight.keywordsPattern": "(todo|TODO|fixme|FIXME)(:?)",
"terminal.integrated.profiles.linux": {
"strapi": {
"path": "docker",
"args": ["exec", "-it", "clic-strapi", "/bin/bash"],
"overrideName": true
},
"postgres": {
"path": "docker",
"args": ["exec", "-it", "clic-postgres", "/bin/bash"],
"overrideName": true
}
},
"terminal.integrated.profiles.windows": {
"strapi": {
"path": "docker",
"args": ["exec", "-it", "clic-strapi", "/bin/bash"],
"overrideName": true
},
"postgres": {
"path": "docker",
"args": ["exec", "-it", "clic-postgres", "/bin/bash"],
"overrideName": true
}
},
"terminal.integrated.profiles.osx": {
"strapi": {
"path": "docker",
"args": ["exec", "-it", "clic-strapi", "/bin/bash"],
"overrideName": true
},
"postgres": {
"path": "docker",
"args": ["exec", "-it", "clic-postgres", "/bin/bash"],
"overrideName": true
}
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
34 changes: 34 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Start dev container",
"type": "shell",
"command": "docker compose --file .devcontainer/docker-compose.yaml up",
"windows": {
"command": "docker compose --file .devcontainer\\docker-compose.yaml up"
},
"group": "none",
"presentation": {
"reveal": "always",
"panel": "new"
},
"runOptions": {
"runOn": "folderOpen"
}
},
{
"label": "Stop dev container",
"type": "shell",
"command": "docker compose --file .devcontainer/docker-compose.yaml down",
"windows": {
"command": "docker compose --file .devcontainer\\docker-compose.yaml down"
},
"group": "none",
"presentation": {
"reveal": "always",
"panel": "new"
}
}
]
}
12 changes: 12 additions & 0 deletions app/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
ARG VARIANT=18-bullseye
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT}

# the root folder will be mounted at /app in the container
WORKDIR /app

# use "node" user with UID/GID 1000 (avoid permission issues with root)
USER node

# install dependencies and run in watch mode
CMD npm install && npm run dev
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/typescript-node
{
"name": "clic-website-devcontainer/strapi",
"name": "clic-website-devcontainer/app",
// Use docker-compose stack, relative to current file
"dockerComposeFile": "../../.devcontainer/docker-compose.yaml",
// Connect VSCode to following service defined in dockerComposeFile
"service": "strapi",
"service": "app",
// Working directory inside devcontainer, where project is located
"workspaceFolder": "/app",
// Configure tool-specific properties.
Expand Down
Loading

0 comments on commit 83b787c

Please sign in to comment.