Setup everything with one click

This commit is contained in:
Felipe Santos 2022-11-14 20:43:58 -03:00
parent 26a681d54a
commit f4b2c3f371
5 changed files with 59 additions and 14 deletions

View File

@ -4,11 +4,39 @@
"service": "devcontainer", "service": "devcontainer",
"workspaceFolder": "/workspace/frigate", "workspaceFolder": "/workspace/frigate",
"initializeCommand": ".devcontainer/initialize.sh", "initializeCommand": ".devcontainer/initialize.sh",
"postCreateCommand": ".devcontainer/post_create.sh",
"overrideCommand": false, "overrideCommand": false,
"remoteUser": "vscode", "remoteUser": "vscode",
"features": { "features": {
"ghcr.io/devcontainers/features/common-utils:1": {} "ghcr.io/devcontainers/features/common-utils:1": {}
}, },
"forwardPorts": [5000, 5001, 5173, 1935, 8554, 8555],
"portsAttributes": {
"5000": {
"label": "NGINX",
"onAutoForward": "silent"
},
"5001": {
"label": "Frigate API",
"onAutoForward": "silent"
},
"5173": {
"label": "Vite Server",
"onAutoForward": "silent"
},
"1935": {
"label": "RTMP",
"onAutoForward": "silent"
},
"8554": {
"label": "gortc RTSP",
"onAutoForward": "silent"
},
"8555": {
"label": "go2rtc WebRTC",
"onAutoForward": "silent"
}
},
"extensions": [ "extensions": [
"ms-python.vscode-pylance", "ms-python.vscode-pylance",
"ms-python.python", "ms-python.python",

View File

@ -2,6 +2,9 @@
set -euo pipefail set -euo pipefail
# These folders needs to be created and owned by the host user
mkdir -p debug web/dist
if [[ -f "config/config.yml" ]]; then if [[ -f "config/config.yml" ]]; then
echo "config/config.yml already exists, skipping initialization" >&2 echo "config/config.yml already exists, skipping initialization" >&2
else else

17
.devcontainer/post_create.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
set -euxo pipefail
# Frigate normal container runs as root, so it have permission to create
# the folders. But the devcontainer runs as the host user, so we need to
# create the folders and give the host user permission to write to them.
sudo mkdir -p /media/frigate
sudo chown -R "$(id -u):$(id -g)" /media/frigate
make version
cd web
npm install
npm run build

View File

@ -141,6 +141,12 @@ RUN S6_ARCH="${TARGETARCH}" \
&& wget -O /tmp/s6-overlay-installer "https://github.com/just-containers/s6-overlay/releases/download/v2.2.0.3/s6-overlay-${S6_ARCH}-installer" \ && wget -O /tmp/s6-overlay-installer "https://github.com/just-containers/s6-overlay/releases/download/v2.2.0.3/s6-overlay-${S6_ARCH}-installer" \
&& chmod +x /tmp/s6-overlay-installer && /tmp/s6-overlay-installer / && chmod +x /tmp/s6-overlay-installer && /tmp/s6-overlay-installer /
EXPOSE 5000
EXPOSE 1935
EXPOSE 8554
EXPOSE 8555
ENTRYPOINT ["/init"]
# Frigate deps with Node.js and NPM # Frigate deps with Node.js and NPM
FROM deps AS deps-node FROM deps AS deps-node
@ -156,6 +162,10 @@ FROM deps-node AS devcontainer
WORKDIR /workspace/frigate WORKDIR /workspace/frigate
RUN apt-get update \
&& apt-get install make -y \
&& rm -rf /var/lib/apt/lists/*
RUN --mount=type=bind,source=./requirements-dev.txt,target=/workspace/frigate/requirements-dev.txt \ RUN --mount=type=bind,source=./requirements-dev.txt,target=/workspace/frigate/requirements-dev.txt \
pip3 install -r requirements-dev.txt pip3 install -r requirements-dev.txt
@ -186,11 +196,4 @@ COPY frigate frigate/
COPY migrations migrations/ COPY migrations migrations/
COPY --from=web-dist / web/ COPY --from=web-dist / web/
EXPOSE 5000
EXPOSE 1935
EXPOSE 8554
EXPOSE 8555
ENTRYPOINT ["/init"]
CMD ["python3", "-u", "-m", "frigate"] CMD ["python3", "-u", "-m", "frigate"]

View File

@ -17,17 +17,11 @@ services:
# - /dev/dri:/dev/dri # for intel hwaccel, needs to be updated for your hardware # - /dev/dri:/dev/dri # for intel hwaccel, needs to be updated for your hardware
volumes: volumes:
- .:/workspace/frigate:cached - .:/workspace/frigate:cached
- ./web/dist:/opt/frigate/web:cached
- /etc/localtime:/etc/localtime:ro - /etc/localtime:/etc/localtime:ro
- ./config/config.yml:/config/config.yml:ro - ./config/config.yml:/config/config.yml:ro
- ./debug:/media/frigate - ./debug:/media/frigate
- /dev/bus/usb:/dev/bus/usb - /dev/bus/usb:/dev/bus/usb
ports:
- "1935:1935"
- "3000:3000"
- "5000:5000"
- "5001:5001"
- "8080:8080"
- "8554:8554"
mqtt: mqtt:
container_name: mqtt container_name: mqtt
image: eclipse-mosquitto:1.6 image: eclipse-mosquitto:1.6