commit
7f5acf1ac5
14 changed files with 82 additions and 37 deletions
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
|
@ -7,6 +7,7 @@ env:
|
|||
JWT_SECRET: "secret"
|
||||
ROOT_FOLDER_HOST: /tipi
|
||||
APPS_REPO_ID: repo-id
|
||||
INTERNAL_IP: 192.168.1.10
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
|
|
|
@ -93,8 +93,9 @@ services:
|
|||
networks:
|
||||
- tipi_main_network
|
||||
environment:
|
||||
- INTERNAL_IP=${INTERNAL_IP}
|
||||
- DOMAIN=${DOMAIN}
|
||||
INTERNAL_IP: ${INTERNAL_IP}
|
||||
DOMAIN: ${DOMAIN}
|
||||
NGINX_PORT: ${NGINX_PORT-80}
|
||||
volumes:
|
||||
- ${PWD}/packages/dashboard/src:/dashboard/src
|
||||
# - /dashboard/node_modules
|
||||
|
|
|
@ -24,8 +24,6 @@ services:
|
|||
stop_grace_period: 1m
|
||||
volumes:
|
||||
- ./data/postgres:/var/lib/postgresql/data
|
||||
ports:
|
||||
- 5432:5432
|
||||
environment:
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
POSTGRES_USER: tipi
|
||||
|
@ -42,8 +40,6 @@ services:
|
|||
image: meienberger/runtipi:rc-${TIPI_VERSION}
|
||||
command: /bin/sh -c "cd /api && npm run start"
|
||||
container_name: api
|
||||
ports:
|
||||
- 3001:3001
|
||||
depends_on:
|
||||
tipi-db:
|
||||
condition: service_healthy
|
||||
|
@ -91,14 +87,13 @@ services:
|
|||
image: meienberger/runtipi:rc-${TIPI_VERSION}
|
||||
command: /bin/sh -c "cd /dashboard && npm run start"
|
||||
container_name: dashboard
|
||||
ports:
|
||||
- 3000:3000
|
||||
networks:
|
||||
- tipi_main_network
|
||||
environment:
|
||||
INTERNAL_IP: ${INTERNAL_IP}
|
||||
NODE_ENV: production
|
||||
DOMAIN: ${DOMAIN}
|
||||
NGINX_PORT: ${NGINX_PORT-80}
|
||||
labels:
|
||||
traefik.enable: true
|
||||
traefik.http.routers.dashboard-redirect.rule: PathPrefix("/")
|
||||
|
|
|
@ -23,8 +23,6 @@ services:
|
|||
stop_grace_period: 1m
|
||||
volumes:
|
||||
- ${PWD}/data/postgres:/var/lib/postgresql/data
|
||||
ports:
|
||||
- 5432:5432
|
||||
environment:
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
POSTGRES_USER: tipi
|
||||
|
@ -42,8 +40,6 @@ services:
|
|||
command: /bin/sh -c "cd /api && npm run start"
|
||||
restart: unless-stopped
|
||||
container_name: api
|
||||
ports:
|
||||
- 3001:3001
|
||||
depends_on:
|
||||
tipi-db:
|
||||
condition: service_healthy
|
||||
|
@ -92,14 +88,13 @@ services:
|
|||
command: /bin/sh -c "cd /dashboard && npm run start"
|
||||
restart: unless-stopped
|
||||
container_name: dashboard
|
||||
ports:
|
||||
- 3000:3000
|
||||
networks:
|
||||
- tipi_main_network
|
||||
environment:
|
||||
INTERNAL_IP: ${INTERNAL_IP}
|
||||
NODE_ENV: production
|
||||
DOMAIN: ${DOMAIN}
|
||||
NGINX_PORT: ${NGINX_PORT-80}
|
||||
labels:
|
||||
traefik.enable: true
|
||||
traefik.http.routers.dashboard-redirect.rule: PathPrefix("/")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "runtipi",
|
||||
"version": "0.6.0",
|
||||
"version": "0.6.1",
|
||||
"description": "A homeserver for everyone",
|
||||
"scripts": {
|
||||
"prepare": "husky install",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "dashboard",
|
||||
"version": "0.6.0",
|
||||
"version": "0.6.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"test": "jest --colors",
|
||||
|
|
|
@ -16,7 +16,7 @@ const fetcher: BareFetcher<any> = (url: string) => {
|
|||
};
|
||||
|
||||
export default function useCachedResources(): IReturnProps {
|
||||
const { data } = useSWR<{ ip: string; domain: string }>('api/ip', fetcher);
|
||||
const { data } = useSWR<{ ip: string; domain: string; port: string }>('api/ip', fetcher);
|
||||
const { baseUrl, setBaseUrl, setInternalIp, setDomain } = useSytemStore();
|
||||
const [isLoadingComplete, setLoadingComplete] = useState(false);
|
||||
const [client, setClient] = useState<ApolloClient<unknown>>();
|
||||
|
@ -35,13 +35,17 @@ export default function useCachedResources(): IReturnProps {
|
|||
}
|
||||
|
||||
useEffect(() => {
|
||||
const { ip, domain } = data || {};
|
||||
const { ip, domain, port } = data || {};
|
||||
if (ip && !baseUrl) {
|
||||
setInternalIp(ip);
|
||||
setDomain(domain);
|
||||
|
||||
if (!domain || domain === 'tipi.localhost') {
|
||||
setBaseUrl(`http://${ip}/api`);
|
||||
if (port === '80') {
|
||||
setBaseUrl(`http://${ip}/api`);
|
||||
} else {
|
||||
setBaseUrl(`http://${ip}:${port}/api`);
|
||||
}
|
||||
} else {
|
||||
setBaseUrl(`https://${domain}/api`);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
export default function ip(_: any, res: any) {
|
||||
const { INTERNAL_IP } = process.env;
|
||||
const { NGINX_PORT } = process.env;
|
||||
const { DOMAIN } = process.env;
|
||||
|
||||
res.status(200).json({ ip: INTERNAL_IP, domain: DOMAIN });
|
||||
res.status(200).json({ ip: INTERNAL_IP, domain: DOMAIN, port: NGINX_PORT });
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "system-api",
|
||||
"version": "0.6.0",
|
||||
"version": "0.6.1",
|
||||
"description": "",
|
||||
"exports": "./dist/server.js",
|
||||
"type": "module",
|
||||
|
|
|
@ -14,6 +14,7 @@ interface IConfig {
|
|||
ROOT_FOLDER_HOST: string;
|
||||
APPS_REPO_ID: string;
|
||||
APPS_REPO_URL: string;
|
||||
INTERNAL_IP: string;
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
|
@ -51,6 +52,7 @@ const config: IConfig = {
|
|||
ROOT_FOLDER_HOST,
|
||||
APPS_REPO_ID,
|
||||
APPS_REPO_URL,
|
||||
INTERNAL_IP,
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
|
|
@ -220,7 +220,6 @@ describe('generateEnvFile', () => {
|
|||
const envmap = await getEnvMap(appInfo.id);
|
||||
|
||||
expect(envmap.get('APP_EXPOSED')).toBeUndefined();
|
||||
expect(envmap.get('APP_DOMAIN')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('Should not add APP_EXPOSED if app is not exposed', async () => {
|
||||
|
@ -233,7 +232,7 @@ describe('generateEnvFile', () => {
|
|||
const envmap = await getEnvMap(appInfo.id);
|
||||
|
||||
expect(envmap.get('APP_EXPOSED')).toBeUndefined();
|
||||
expect(envmap.get('APP_DOMAIN')).toBeUndefined();
|
||||
expect(envmap.get('APP_DOMAIN')).toBe(`192.168.1.10:${appInfo.port}`);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ describe('Install app', () => {
|
|||
await AppsService.installApp(app1.id, { TEST_FIELD: 'test' });
|
||||
const envFile = fs.readFileSync(`${config.ROOT_FOLDER}/app-data/${app1.id}/app.env`).toString();
|
||||
|
||||
expect(envFile.trim()).toBe(`TEST=test\nAPP_PORT=${app1.port}\nTEST_FIELD=test`);
|
||||
expect(envFile.trim()).toBe(`TEST=test\nAPP_PORT=${app1.port}\nTEST_FIELD=test\nAPP_DOMAIN=192.168.1.10:${app1.port}`);
|
||||
});
|
||||
|
||||
it('Should add app in database', async () => {
|
||||
|
@ -272,7 +272,7 @@ describe('Start app', () => {
|
|||
|
||||
const envFile = fs.readFileSync(`${config.ROOT_FOLDER}/app-data/${app1.id}/app.env`).toString();
|
||||
|
||||
expect(envFile.trim()).toBe(`TEST=test\nAPP_PORT=${app1.port}\nTEST_FIELD=test`);
|
||||
expect(envFile.trim()).toBe(`TEST=test\nAPP_PORT=${app1.port}\nTEST_FIELD=test\nAPP_DOMAIN=192.168.1.10:${app1.port}`);
|
||||
});
|
||||
|
||||
it('Should throw if start script fails', async () => {
|
||||
|
@ -336,7 +336,7 @@ describe('Update app config', () => {
|
|||
|
||||
const envFile = fs.readFileSync(`${config.ROOT_FOLDER}/app-data/${app1.id}/app.env`).toString();
|
||||
|
||||
expect(envFile.trim()).toBe(`TEST=test\nAPP_PORT=${app1.port}\nTEST_FIELD=test`);
|
||||
expect(envFile.trim()).toBe(`TEST=test\nAPP_PORT=${app1.port}\nTEST_FIELD=test\nAPP_DOMAIN=192.168.1.10:${app1.port}`);
|
||||
});
|
||||
|
||||
it('Should throw if required field is missing', async () => {
|
||||
|
|
|
@ -108,6 +108,9 @@ export const generateEnvFile = (app: App) => {
|
|||
if (app.exposed && app.domain) {
|
||||
envFile += 'APP_EXPOSED=true\n';
|
||||
envFile += `APP_DOMAIN=${app.domain}\n`;
|
||||
envFile += 'APP_PROTOCOL=https\n';
|
||||
} else {
|
||||
envFile += `APP_DOMAIN=${config.INTERNAL_IP}:${configFile.port}\n`;
|
||||
}
|
||||
|
||||
writeFile(`/app-data/${app.id}/app.env`, envFile);
|
||||
|
@ -161,7 +164,9 @@ export const getAppInfo = (id: string, status?: AppStatusEnum): AppInfo | null =
|
|||
export const getUpdateInfo = async (id: string) => {
|
||||
const app = await App.findOne({ where: { id } });
|
||||
|
||||
if (!app) {
|
||||
const doesFileExist = fileExists(`/repos/${config.APPS_REPO_ID}/apps/${id}`);
|
||||
|
||||
if (!app || !doesFileExist) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,42 +16,42 @@ function install_docker() {
|
|||
local os="${1}"
|
||||
echo "Installing docker for os ${os}" >/dev/tty
|
||||
|
||||
if [[ "${OS}" == "debian" ]]; then
|
||||
if [[ "${os}" == "debian" ]]; then
|
||||
sudo apt-get update
|
||||
sudo apt-get upgrade
|
||||
sudo apt-get install -y ca-certificates curl gnupg jq lsb-release
|
||||
sudo apt-get install -y ca-certificates curl gnupg lsb-release
|
||||
sudo mkdir -p /etc/apt/keyrings
|
||||
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
return 0
|
||||
elif [[ "${OS}" == "ubuntu" ]]; then
|
||||
elif [[ "${os}" == "ubuntu" ]]; then
|
||||
sudo apt-get update
|
||||
sudo apt-get upgrade
|
||||
sudo apt-get install -y ca-certificates curl gnupg jq lsb-release
|
||||
sudo apt-get install -y ca-certificates curl gnupg lsb-release
|
||||
sudo mkdir -p /etc/apt/keyrings
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
return 0
|
||||
elif [[ "${OS}" == "centos" ]]; then
|
||||
sudo yum install -y yum-utils jq
|
||||
elif [[ "${os}" == "centos" ]]; then
|
||||
sudo yum install -y yum-utils
|
||||
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
|
||||
sudo yum install -y --allowerasing docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
sudo systemctl start docker
|
||||
sudo systemctl enable docker
|
||||
return 0
|
||||
elif [[ "${OS}" == "fedora" ]]; then
|
||||
sudo dnf -y install dnf-plugins-core jq
|
||||
elif [[ "${os}" == "fedora" ]]; then
|
||||
sudo dnf -y install dnf-plugins-core
|
||||
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
|
||||
sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||
sudo systemctl start docker
|
||||
sudo systemctl enable docker
|
||||
return 0
|
||||
elif [[ "${OS}" == "arch" ]]; then
|
||||
sudo pacman -Sy --noconfirm docker jq
|
||||
elif [[ "${os}" == "arch" ]]; then
|
||||
sudo pacman -Sy --noconfirm docker
|
||||
sudo systemctl start docker.service
|
||||
sudo systemctl enable docker.service
|
||||
|
||||
|
@ -66,6 +66,28 @@ function install_docker() {
|
|||
fi
|
||||
}
|
||||
|
||||
function install_jq() {
|
||||
local os="${1}"
|
||||
echo "Installing jq for os ${os}" >/dev/tty
|
||||
|
||||
if [[ "${os}" == "debian" || "${os}" == "ubuntu" ]]; then
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y jq
|
||||
return 0
|
||||
elif [[ "${os}" == "centos" ]]; then
|
||||
sudo yum install -y jq
|
||||
return 0
|
||||
elif [[ "${os}" == "fedora" ]]; then
|
||||
sudo dnf -y install jq
|
||||
return 0
|
||||
elif [[ "${os}" == "arch" ]]; then
|
||||
sudo pacman -Sy --noconfirm jq
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
OS="$(cat /etc/[A-Za-z]*[_-][rv]e[lr]* | grep "^ID=" | cut -d= -f2 | uniq | tr '[:upper:]' '[:lower:]' | tr -d '"')"
|
||||
SUB_OS="$(cat /etc/[A-Za-z]*[_-][rv]e[lr]* | grep "^ID_LIKE=" | cut -d= -f2 | uniq | tr '[:upper:]' '[:lower:]' | tr -d '"')"
|
||||
|
||||
|
@ -95,3 +117,23 @@ if ! command -v docker-compose >/dev/null; then
|
|||
sudo curl -L "https://github.com/docker/compose/releases/download/v2.3.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||
sudo chmod +x /usr/local/bin/docker-compose
|
||||
fi
|
||||
|
||||
if ! command -v jq >/dev/null; then
|
||||
install_jq "${OS}"
|
||||
jq_result=$?
|
||||
|
||||
if [[ jq_result -eq 0 ]]; then
|
||||
echo "jq installed"
|
||||
else
|
||||
echo "Your system ${OS} is not supported trying with sub_os ${SUB_OS}"
|
||||
install_jq "${SUB_OS}"
|
||||
jq_sub_result=$?
|
||||
|
||||
if [[ jq_sub_result -eq 0 ]]; then
|
||||
echo "jq installed"
|
||||
else
|
||||
echo "Your system ${SUB_OS} is not supported please install jq manually"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue