mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-26 20:34:10 +01:00
refactor: split docker install with env
This commit is contained in:
parent
104dc9a08e
commit
a950f57ee6
4 changed files with 33 additions and 21 deletions
2
.devcontainer/.env.example
Normal file
2
.devcontainer/.env.example
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
# When running devcontainers, you can specify if docker & docker-compose should be installed in your environment
|
||||||
|
INSTALL_DOCKER=false
|
||||||
|
|
@ -1,16 +1,22 @@
|
||||||
FROM node:18-bullseye
|
FROM node:18-bullseye
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y sudo
|
ARG INSTALL_DOCKER="false"
|
||||||
RUN useradd -m -s /bin/bash vscode && echo "vscode ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/vscode
|
ENV INSTALL_DOCKER=${INSTALL_DOCKER}
|
||||||
RUN mkdir -p /workspaces && chown -R vscode:vscode /workspaces
|
|
||||||
WORKDIR /workspaces
|
|
||||||
|
|
||||||
# Install Docker and Docker Compose
|
# Install Docker and Docker Compose only if INSTALL_DOCKER is "true"
|
||||||
RUN apt-get update && \
|
RUN if [ "$INSTALL_DOCKER" = "true" ]; then \
|
||||||
apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release && \
|
apt-get update && \
|
||||||
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \
|
apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release && \
|
||||||
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \
|
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \
|
||||||
apt-get update && \
|
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \
|
||||||
apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
apt-get update && \
|
||||||
|
apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set up non-root user
|
||||||
|
RUN useradd -m -s /bin/bash vscode
|
||||||
|
RUN if [ "$INSTALL_DOCKER" = "true" ]; then usermod -aG docker vscode; fi
|
||||||
|
|
||||||
USER vscode
|
USER vscode
|
||||||
|
|
||||||
|
WORKDIR /workspaces
|
||||||
|
|
|
||||||
|
|
@ -5,17 +5,19 @@
|
||||||
"workspaceFolder": "/workspaces",
|
"workspaceFolder": "/workspaces",
|
||||||
"customizations": {
|
"customizations": {
|
||||||
"vscode": {
|
"vscode": {
|
||||||
"extensions": ["ms-azuretools.vscode-docker"],
|
"extensions": ["ms-azuretools.vscode-docker"]
|
||||||
"settings": {
|
|
||||||
"terminal.integrated.defaultProfile.linux": "bash"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"postCreateCommand": "sudo apt-get update && sudo apt-get install -y docker.io docker-compose",
|
|
||||||
"features": {
|
"features": {
|
||||||
"ghcr.io/devcontainers/features/git:1": {},
|
"ghcr.io/devcontainers/features/docker-in-docker:2": {
|
||||||
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
|
"version": "latest",
|
||||||
|
"moby": true,
|
||||||
|
"dockerDashComposeVersion": "v2"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"remoteUser": "vscode",
|
"remoteUser": "vscode",
|
||||||
"forwardPorts": [3080, 27017, 7700]
|
"postCreateCommand": "sudo chown -R vscode:vscode /workspaces && if [ \"$CODESPACES\" = \"true\" ]; then sudo apt-get update && sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin; fi",
|
||||||
|
"remoteEnv": {
|
||||||
|
"INSTALL_DOCKER": "${localEnv:INSTALL_DOCKER:false}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ services:
|
||||||
build:
|
build:
|
||||||
context: ..
|
context: ..
|
||||||
dockerfile: .devcontainer/Dockerfile
|
dockerfile: .devcontainer/Dockerfile
|
||||||
|
args:
|
||||||
|
- INSTALL_DOCKER=${INSTALL_DOCKER:-false}
|
||||||
# restart: always
|
# restart: always
|
||||||
links:
|
links:
|
||||||
- mongodb
|
- mongodb
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue