Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add development reverse proxy #39

Merged
merged 10 commits into from
Aug 10, 2023
24 changes: 24 additions & 0 deletions .devcontainer/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,30 @@ services:
volumes:
- "strapi-data:/var/lib/postgresql/data"

app:
Thechi2000 marked this conversation as resolved.
Show resolved Hide resolved
# 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:
- "../Caddyfile-dev:/etc/caddy/Caddyfile"
Thechi2000 marked this conversation as resolved.
Show resolved Hide resolved
ports:
- "3000:3000"
Thechi2000 marked this conversation as resolved.
Show resolved Hide resolved

volumes:
# Persist strapi database
strapi-data:
12 changes: 12 additions & 0 deletions Caddyfile-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
auto_https off
}

http://localhost:3000 {
reverse_proxy /api* http://strapi:8001
reverse_proxy /admin* http://strapi:8001
reverse_proxy /i18n* http://strapi:8001
reverse_proxy /content-manager* http://strapi:8001

reverse_proxy http://app:3000
}
Thechi2000 marked this conversation as resolved.
Show resolved Hide resolved
Thechi2000 marked this conversation as resolved.
Show resolved Hide resolved
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
Thechi2000 marked this conversation as resolved.
Show resolved Hide resolved
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
33 changes: 33 additions & 0 deletions app/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// strapi service devcontainer
Thechi2000 marked this conversation as resolved.
Show resolved Hide resolved
// 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/app",
// Use docker-compose stack, relative to current file
"dockerComposeFile": "../../.devcontainer/docker-compose.yaml",
// Connect VSCode to following service defined in dockerComposeFile
"service": "app",
// Working directory inside devcontainer, where project is located
"workspaceFolder": "/app",
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
// todo highlighter
"wayou.vscode-todo-highlight",
// linter
"dbaeumer.vscode-eslint",
// formatter
"esbenp.prettier-vscode"
]
}
},
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "node"
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",
}
19 changes: 10 additions & 9 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading