From 9f0f675d2939d5f0ddf8580711b8b0d187b2d773 Mon Sep 17 00:00:00 2001 From: Luca Steccanella Date: Thu, 9 Dec 2021 17:18:19 +0100 Subject: [PATCH 1/7] Update README.md --- README.md | 114 ++++++++---------------------------------------------- 1 file changed, 16 insertions(+), 98 deletions(-) diff --git a/README.md b/README.md index 3c3531a..bb4ebc6 100644 --- a/README.md +++ b/README.md @@ -1,53 +1,27 @@ -# xBrowserSync -## API for Docker +# xBrowserSync-clean-docker +## xBrowserSync API for Docker -![](https://img.shields.io/docker/pulls/xbrowsersync/api.svg) -![](https://img.shields.io/docker/stars/xbrowsersync/api.svg) +Hi, this is custom version of the [official xBrowserSync Docker](https://github.com/xbrowsersync/api-docker). +I made it to simplify my personal deployment and fit my personal needs. -xBrowserSync is a free tool for syncing browser data between different browsers and devices, built for privacy and anonymity. For full details, see [www.xbrowsersync.org](https://www.xbrowsersync.org/). - -This repository contains the Docker files required to get your own [xBrowserSync API service](https://github.com/xbrowsersync/api) up and running in moments, either by running the API image alone or by orchestrating a production-ready HTTPS service with database and reverse proxy. - -## Running the API image - -Running the API image alone requires that you have a MongoDB instance and (ideally) a web server to reverse proxy the API behind. - - 1. Create a file named `settings.json` and include any required custom [settings](https://github.com/xbrowsersync/api#3-modify-configuration-settings) values, such as those for connecting to your MongoDB instance. For example, if you are running Docker and MongoDB on a windows server, you would point the service at the MongoDB instance running on the host using the following settings: - - ``` - { - "db": { - "host": "host.docker.internal" - } - } - ``` - - 2. (Optionally) create the following environment variables on your host to store the username and password required to access the xBrowserSync database on your MongoDB instance: - - - XBROWSERSYNC_DB_USER - - XBROWSERSYNC_DB_PWD - - 3. Run the following command to start an API container, providing the actual path to the `settings.json` file created in step 1. The service will be exposed via port 8080. If you did not create the environment variables in step 2, you will need to provide the actual username and password values in line, i.e. `-e XBROWSERSYNC_DB_USER=YourDatabaseUsername -e XBROWSERSYNC_DB_PWD=YourDatabasePassword`: - - ``` - docker run --name xbs-api -p 8080:8080 -e XBROWSERSYNC_DB_USER -e XBROWSERSYNC_DB_PWD -v /path/to/settings.json:/usr/src/api/config/settings.json -d xbrowsersync/api - ``` - - You can now access your xBrowserSync API service at http://127.0.0.1:8080. +## Changes made +- [healthcheck.js](healthcheck.js) and [settings.json](settings.json) are going to be copied inside the container by the [dockerfile](dockerfile); so it will not longer be necessary to be mounted as volumes in [docker-compose.yml](docker-compose.yml) unless needed. +- [dockerfile](dockerfile) will build from latest alpine +- [dockerfile](dockerfile) will get latest version of [xBrowserSync API](https://github.com/xbrowsersync/api) +- [docker-compose.yml](docker-compose.yml) will fetch latest version of the image. +- Removed caddy, so you can integrate the containers with an existing proxy like Traefik or Jwilder's proxy. ## Running a production-ready service -If you do not already have a MongoDB instance or are intending to expose your xBrowserSync service over the internet then it is recommended to use the provided [`docker-compose.yml`](https://github.com/xbrowsersync/api-docker/blob/master/docker-compose.yml) which will create fully configured containers for a MongoDB database, the xBrowserSync API and a [Caddy](https://caddyserver.com/) web server as a reverse proxy in front of the API. Caddy automatically acquires and updates SSL certificates so that your xBrowserSync API service will run securely over HTTPS. - - 1. Clone the [api-docker](https://github.com/xbrowsersync/api-docker/) GitHub repo: + 1. Clone the [this repo](https://github.com/Steccas/api-docker): ``` - git clone https://github.com/xbrowsersync/api-docker.git + git clone https://github.com/Steccas/api-docker.git ``` - 2. Open the [`.env`](https://github.com/xbrowsersync/api-docker/blob/master/.env) file in a text editor and update the `API_HOSTNAME` value to correspond to the host name that the API service will be exposed over (ensure you have configured your DNS provider to point the desired host name to your host's IP address). Also, change the `DB_USERNAME` and `DB_PASSWORD` values to any of your choosing. + 2. Open the [`.env`](.env) file in a text editor and update the `API_HOSTNAME` value to correspond to the host name that the API service will be exposed over (ensure you have configured your DNS provider to point the desired host name to your host's IP address). Also, change the `DB_USERNAME` and `DB_PASSWORD` values to any of your choosing. - 3. (Optionally) open the [`settings.json`](https://github.com/xbrowsersync/api-docker/blob/master/settings.json) file and include any custom [settings](https://github.com/xbrowsersync/api#3-modify-configuration-settings) values you wish to run on your service. Important: do not change the `db.host` value. + 3. (Optionally) open the [`settings.json`](settings.json) file and include any custom [settings](https://github.com/xbrowsersync/api#3-modify-configuration-settings) values you wish to run on your service. Important: do not change the `db.host` value. And remember in this case to uncomment the volume mounting in [docker-compose.yml](docker-compose.yml). 4. Run the following command to start the containers: @@ -55,63 +29,7 @@ If you do not already have a MongoDB instance or are intending to expose your xB docker-compose up -d ``` - You can now access your xBrowserSync API service over HTTPS at the value of `API_HOSTNAME` defined in the [`.env`](https://github.com/xbrowsersync/api-docker/blob/master/.env) file. - -## Upgrade process - -If you wish to upgrade your existing production-ready service created using the [`docker-compose.yml`](https://github.com/xbrowsersync/api-docker/blob/master/docker-compose.yml) file, you may encounter database errors when upgrading the MongoDB version. To avoid these issues, it is recommended that you export the db data from the old version and restore to the new version once up and running. - -The following steps detail the process in full: - - - 1. Connect to the MongoDB container: - - ``` - docker exec -it xbs-db bash - ``` - - 2. Export db data to the `xbs-db-backups` Docker volume using [mongodump](https://docs.mongodb.com/database-tools/mongodump/): - - ``` - mongodump --db $XBS_DB_NAME --host localhost --port 27017 --username $XBS_DB_USERNAME --password $XBS_DB_PASSWORD --authenticationDatabase admin --archive=/data/backups/xbs-db-`date +"%Y-%m-%d"`.gz --gzip - ``` - - 3. Exit the MongoDB container and navigate to the api-docker GitHub repo folder. Stop and remove all containers: - - ``` - docker-compose down - ``` - - 4. Delete the `xbs-db-data` Docker volume before upgrading MongoDB. You need to find the volume name first using: - - ``` - docker volume ls - ``` - - It will be something like `api-docker_xbs-db-data`. Once located, delete it with: - - ``` - docker volume rm api-docker_xbs-db-data - ``` - - 5. Get latest changes and start the containers: - - ``` - git pull - docker-compose up -d - ``` - 6. Connect to the MongoDB container: - - ``` - docker exec -it xbs-db bash - ``` - - 7. Restore db data from the `xbs-db-backups` Docker volume using [mongorestore](https://docs.mongodb.com/database-tools/mongorestore/) (replace `{BackupFileName}` with the actual backup file name): - - ``` - mongorestore --username $XBS_DB_USERNAME --password $XBS_DB_PASSWORD --authenticationDatabase admin --verbose=5 --gzip --drop --archive=/data/backups/{BackupFileName} - ``` + You can now access your xBrowserSync API service at the value of `API_HOSTNAME` defined in the [`.env`](.env) file. ## Issues and feature requests - -Please log Docker-related issues in the [api-docker Issues list](https://github.com/xbrowsersync/api-docker/issues), if you have found an issue with the xBrowserSync API itself or wish to request a new feature, do so in the [api Issues list](https://github.com/xbrowsersync/api/issues/). +Please cosnider that this is just a fork, so if the problem doesn't exists just in this implementation please log Docker-related issues directly in the [api-docker Issues list](https://github.com/xbrowsersync/api-docker/issues), if you have found an issue with the xBrowserSync API itself or wish to request a new feature, do so in the [api Issues list](https://github.com/xbrowsersync/api/issues/). From a9ad1a3b2804c1b4282518936ca3287347e1967d Mon Sep 17 00:00:00 2001 From: Luca Steccanella Date: Fri, 10 Dec 2021 13:49:39 +0100 Subject: [PATCH 2/7] First modifications --- docker-compose.yml | 19 ++----------------- dockerfile | 2 +- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 21d837e..e2e8fb9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: - "XBS_DB_NAME=$DB_NAME" - "XBS_DB_PASSWORD=$DB_PASSWORD" - "XBS_DB_USERNAME=$DB_USERNAME" - image: "mongo:4.4.4" + image: "mongo:latest" restart: "unless-stopped" volumes: - "xbs-db-data:/data/db" @@ -29,27 +29,12 @@ services: timeout: "10s" retries: "5" start_period: "30s" - image: "xbrowsersync/api:1.1.13" + image: "xbrowsersync/api:latest" restart: "unless-stopped" volumes: - "./settings.json:/usr/src/api/config/settings.json" - "./healthcheck.js:/usr/src/api/healthcheck.js" - reverse-proxy: - command: "caddy reverse-proxy --from $API_HOSTNAME --to api:8080" - container_name: "xbs-reverse-proxy" - depends_on: - - "api" - image: "caddy:2.3.0-alpine" - ports: - - "443:443" - - "80:80" - restart: "unless-stopped" - volumes: - - "xbs-caddy-config:/config" - - "xbs-caddy-data:/data" volumes: - xbs-caddy-config: - xbs-caddy-data: xbs-db-backups: xbs-db-data: diff --git a/dockerfile b/dockerfile index 10cd4b3..9435e16 100644 --- a/dockerfile +++ b/dockerfile @@ -1,4 +1,4 @@ -FROM node:14.16.0-alpine +FROM node:fermium-alpine # Set environment variables ENV XBROWSERSYNC_API_VERSION 1.1.13 From 5b8b02b8a3c4c8e215510e9b70b614a6a5fa1c73 Mon Sep 17 00:00:00 2001 From: Luca Steccanella Date: Fri, 10 Dec 2021 14:22:37 +0100 Subject: [PATCH 3/7] Added automatic fetching of latest api version --- dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dockerfile b/dockerfile index 9435e16..c0a65ff 100644 --- a/dockerfile +++ b/dockerfile @@ -1,14 +1,18 @@ FROM node:fermium-alpine # Set environment variables -ENV XBROWSERSYNC_API_VERSION 1.1.13 +#ENV XBROWSERSYNC_API_VERSION 1.1.13 WORKDIR /usr/src/api # Download release and unpack -RUN wget -q -O release.tar.gz https://github.com/xBrowserSync/api/archive/v$XBROWSERSYNC_API_VERSION.tar.gz \ +RUN apk update && apk add grep curl +RUN XBROWSERSYNC_API_VERSION="$(curl --silent "https://api.github.com/repos/xbrowsersync/api/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')" \ + && echo $XBROWSERSYNC_API_VERSION \ + && wget -q -O release.tar.gz https://github.com/xBrowserSync/api/archive/$XBROWSERSYNC_API_VERSION.tar.gz \ && tar -C . -xzf release.tar.gz \ && rm release.tar.gz \ + && XBROWSERSYNC_API_VERSION="${XBROWSERSYNC_API_VERSION:1}" \ && mv api-$XBROWSERSYNC_API_VERSION/* . \ && rm -rf api-$XBROWSERSYNC_API_VERSION/ From 881cd04cdfda1e7a4cdb79586a150b604a7f4e46 Mon Sep 17 00:00:00 2001 From: Luca Steccanella Date: Fri, 10 Dec 2021 14:31:12 +0100 Subject: [PATCH 4/7] Fix possible dependencies error for npm --- dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/dockerfile b/dockerfile index c0a65ff..cb78112 100644 --- a/dockerfile +++ b/dockerfile @@ -17,6 +17,7 @@ RUN XBROWSERSYNC_API_VERSION="$(curl --silent "https://api.github.com/repos/xbro && rm -rf api-$XBROWSERSYNC_API_VERSION/ # Install dependencies +RUN apk add python2 make RUN npm install --only=production # Expose port and start api From 03ff9eac29a7b4310a383d6e0f3f7eddd1afc605 Mon Sep 17 00:00:00 2001 From: Luca Steccanella Date: Fri, 10 Dec 2021 14:50:23 +0100 Subject: [PATCH 5/7] Revert to original repo --- README.md | 114 ++++++++++++++++++++++++++++++++++++++------- docker-compose.yml | 19 +++++++- dockerfile | 11 ++--- 3 files changed, 118 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index bb4ebc6..3c3531a 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,53 @@ -# xBrowserSync-clean-docker -## xBrowserSync API for Docker +# xBrowserSync +## API for Docker -Hi, this is custom version of the [official xBrowserSync Docker](https://github.com/xbrowsersync/api-docker). -I made it to simplify my personal deployment and fit my personal needs. +![](https://img.shields.io/docker/pulls/xbrowsersync/api.svg) +![](https://img.shields.io/docker/stars/xbrowsersync/api.svg) -## Changes made -- [healthcheck.js](healthcheck.js) and [settings.json](settings.json) are going to be copied inside the container by the [dockerfile](dockerfile); so it will not longer be necessary to be mounted as volumes in [docker-compose.yml](docker-compose.yml) unless needed. -- [dockerfile](dockerfile) will build from latest alpine -- [dockerfile](dockerfile) will get latest version of [xBrowserSync API](https://github.com/xbrowsersync/api) -- [docker-compose.yml](docker-compose.yml) will fetch latest version of the image. -- Removed caddy, so you can integrate the containers with an existing proxy like Traefik or Jwilder's proxy. +xBrowserSync is a free tool for syncing browser data between different browsers and devices, built for privacy and anonymity. For full details, see [www.xbrowsersync.org](https://www.xbrowsersync.org/). + +This repository contains the Docker files required to get your own [xBrowserSync API service](https://github.com/xbrowsersync/api) up and running in moments, either by running the API image alone or by orchestrating a production-ready HTTPS service with database and reverse proxy. + +## Running the API image + +Running the API image alone requires that you have a MongoDB instance and (ideally) a web server to reverse proxy the API behind. + + 1. Create a file named `settings.json` and include any required custom [settings](https://github.com/xbrowsersync/api#3-modify-configuration-settings) values, such as those for connecting to your MongoDB instance. For example, if you are running Docker and MongoDB on a windows server, you would point the service at the MongoDB instance running on the host using the following settings: + + ``` + { + "db": { + "host": "host.docker.internal" + } + } + ``` + + 2. (Optionally) create the following environment variables on your host to store the username and password required to access the xBrowserSync database on your MongoDB instance: + + - XBROWSERSYNC_DB_USER + - XBROWSERSYNC_DB_PWD + + 3. Run the following command to start an API container, providing the actual path to the `settings.json` file created in step 1. The service will be exposed via port 8080. If you did not create the environment variables in step 2, you will need to provide the actual username and password values in line, i.e. `-e XBROWSERSYNC_DB_USER=YourDatabaseUsername -e XBROWSERSYNC_DB_PWD=YourDatabasePassword`: + + ``` + docker run --name xbs-api -p 8080:8080 -e XBROWSERSYNC_DB_USER -e XBROWSERSYNC_DB_PWD -v /path/to/settings.json:/usr/src/api/config/settings.json -d xbrowsersync/api + ``` + + You can now access your xBrowserSync API service at http://127.0.0.1:8080. ## Running a production-ready service - 1. Clone the [this repo](https://github.com/Steccas/api-docker): +If you do not already have a MongoDB instance or are intending to expose your xBrowserSync service over the internet then it is recommended to use the provided [`docker-compose.yml`](https://github.com/xbrowsersync/api-docker/blob/master/docker-compose.yml) which will create fully configured containers for a MongoDB database, the xBrowserSync API and a [Caddy](https://caddyserver.com/) web server as a reverse proxy in front of the API. Caddy automatically acquires and updates SSL certificates so that your xBrowserSync API service will run securely over HTTPS. + + 1. Clone the [api-docker](https://github.com/xbrowsersync/api-docker/) GitHub repo: ``` - git clone https://github.com/Steccas/api-docker.git + git clone https://github.com/xbrowsersync/api-docker.git ``` - 2. Open the [`.env`](.env) file in a text editor and update the `API_HOSTNAME` value to correspond to the host name that the API service will be exposed over (ensure you have configured your DNS provider to point the desired host name to your host's IP address). Also, change the `DB_USERNAME` and `DB_PASSWORD` values to any of your choosing. + 2. Open the [`.env`](https://github.com/xbrowsersync/api-docker/blob/master/.env) file in a text editor and update the `API_HOSTNAME` value to correspond to the host name that the API service will be exposed over (ensure you have configured your DNS provider to point the desired host name to your host's IP address). Also, change the `DB_USERNAME` and `DB_PASSWORD` values to any of your choosing. - 3. (Optionally) open the [`settings.json`](settings.json) file and include any custom [settings](https://github.com/xbrowsersync/api#3-modify-configuration-settings) values you wish to run on your service. Important: do not change the `db.host` value. And remember in this case to uncomment the volume mounting in [docker-compose.yml](docker-compose.yml). + 3. (Optionally) open the [`settings.json`](https://github.com/xbrowsersync/api-docker/blob/master/settings.json) file and include any custom [settings](https://github.com/xbrowsersync/api#3-modify-configuration-settings) values you wish to run on your service. Important: do not change the `db.host` value. 4. Run the following command to start the containers: @@ -29,7 +55,63 @@ I made it to simplify my personal deployment and fit my personal needs. docker-compose up -d ``` - You can now access your xBrowserSync API service at the value of `API_HOSTNAME` defined in the [`.env`](.env) file. + You can now access your xBrowserSync API service over HTTPS at the value of `API_HOSTNAME` defined in the [`.env`](https://github.com/xbrowsersync/api-docker/blob/master/.env) file. + +## Upgrade process + +If you wish to upgrade your existing production-ready service created using the [`docker-compose.yml`](https://github.com/xbrowsersync/api-docker/blob/master/docker-compose.yml) file, you may encounter database errors when upgrading the MongoDB version. To avoid these issues, it is recommended that you export the db data from the old version and restore to the new version once up and running. + +The following steps detail the process in full: + + + 1. Connect to the MongoDB container: + + ``` + docker exec -it xbs-db bash + ``` + + 2. Export db data to the `xbs-db-backups` Docker volume using [mongodump](https://docs.mongodb.com/database-tools/mongodump/): + + ``` + mongodump --db $XBS_DB_NAME --host localhost --port 27017 --username $XBS_DB_USERNAME --password $XBS_DB_PASSWORD --authenticationDatabase admin --archive=/data/backups/xbs-db-`date +"%Y-%m-%d"`.gz --gzip + ``` + + 3. Exit the MongoDB container and navigate to the api-docker GitHub repo folder. Stop and remove all containers: + + ``` + docker-compose down + ``` + + 4. Delete the `xbs-db-data` Docker volume before upgrading MongoDB. You need to find the volume name first using: + + ``` + docker volume ls + ``` + + It will be something like `api-docker_xbs-db-data`. Once located, delete it with: + + ``` + docker volume rm api-docker_xbs-db-data + ``` + + 5. Get latest changes and start the containers: + + ``` + git pull + docker-compose up -d + ``` + 6. Connect to the MongoDB container: + + ``` + docker exec -it xbs-db bash + ``` + + 7. Restore db data from the `xbs-db-backups` Docker volume using [mongorestore](https://docs.mongodb.com/database-tools/mongorestore/) (replace `{BackupFileName}` with the actual backup file name): + + ``` + mongorestore --username $XBS_DB_USERNAME --password $XBS_DB_PASSWORD --authenticationDatabase admin --verbose=5 --gzip --drop --archive=/data/backups/{BackupFileName} + ``` ## Issues and feature requests -Please cosnider that this is just a fork, so if the problem doesn't exists just in this implementation please log Docker-related issues directly in the [api-docker Issues list](https://github.com/xbrowsersync/api-docker/issues), if you have found an issue with the xBrowserSync API itself or wish to request a new feature, do so in the [api Issues list](https://github.com/xbrowsersync/api/issues/). + +Please log Docker-related issues in the [api-docker Issues list](https://github.com/xbrowsersync/api-docker/issues), if you have found an issue with the xBrowserSync API itself or wish to request a new feature, do so in the [api Issues list](https://github.com/xbrowsersync/api/issues/). diff --git a/docker-compose.yml b/docker-compose.yml index e2e8fb9..21d837e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: - "XBS_DB_NAME=$DB_NAME" - "XBS_DB_PASSWORD=$DB_PASSWORD" - "XBS_DB_USERNAME=$DB_USERNAME" - image: "mongo:latest" + image: "mongo:4.4.4" restart: "unless-stopped" volumes: - "xbs-db-data:/data/db" @@ -29,12 +29,27 @@ services: timeout: "10s" retries: "5" start_period: "30s" - image: "xbrowsersync/api:latest" + image: "xbrowsersync/api:1.1.13" restart: "unless-stopped" volumes: - "./settings.json:/usr/src/api/config/settings.json" - "./healthcheck.js:/usr/src/api/healthcheck.js" + reverse-proxy: + command: "caddy reverse-proxy --from $API_HOSTNAME --to api:8080" + container_name: "xbs-reverse-proxy" + depends_on: + - "api" + image: "caddy:2.3.0-alpine" + ports: + - "443:443" + - "80:80" + restart: "unless-stopped" + volumes: + - "xbs-caddy-config:/config" + - "xbs-caddy-data:/data" volumes: + xbs-caddy-config: + xbs-caddy-data: xbs-db-backups: xbs-db-data: diff --git a/dockerfile b/dockerfile index cb78112..10cd4b3 100644 --- a/dockerfile +++ b/dockerfile @@ -1,23 +1,18 @@ -FROM node:fermium-alpine +FROM node:14.16.0-alpine # Set environment variables -#ENV XBROWSERSYNC_API_VERSION 1.1.13 +ENV XBROWSERSYNC_API_VERSION 1.1.13 WORKDIR /usr/src/api # Download release and unpack -RUN apk update && apk add grep curl -RUN XBROWSERSYNC_API_VERSION="$(curl --silent "https://api.github.com/repos/xbrowsersync/api/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')" \ - && echo $XBROWSERSYNC_API_VERSION \ - && wget -q -O release.tar.gz https://github.com/xBrowserSync/api/archive/$XBROWSERSYNC_API_VERSION.tar.gz \ +RUN wget -q -O release.tar.gz https://github.com/xBrowserSync/api/archive/v$XBROWSERSYNC_API_VERSION.tar.gz \ && tar -C . -xzf release.tar.gz \ && rm release.tar.gz \ - && XBROWSERSYNC_API_VERSION="${XBROWSERSYNC_API_VERSION:1}" \ && mv api-$XBROWSERSYNC_API_VERSION/* . \ && rm -rf api-$XBROWSERSYNC_API_VERSION/ # Install dependencies -RUN apk add python2 make RUN npm install --only=production # Expose port and start api From d2715c72c20c8e7ccca79aa4accb7c6ce0439483 Mon Sep 17 00:00:00 2001 From: Luca Steccanella Date: Fri, 10 Dec 2021 14:54:28 +0100 Subject: [PATCH 6/7] Automatic latest v & dependency fix --- docker-compose.yml | 6 +++--- dockerfile | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 21d837e..dd27a00 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: - "XBS_DB_NAME=$DB_NAME" - "XBS_DB_PASSWORD=$DB_PASSWORD" - "XBS_DB_USERNAME=$DB_USERNAME" - image: "mongo:4.4.4" + image: "mongo:latest" restart: "unless-stopped" volumes: - "xbs-db-data:/data/db" @@ -29,7 +29,7 @@ services: timeout: "10s" retries: "5" start_period: "30s" - image: "xbrowsersync/api:1.1.13" + image: "xbrowsersync/api:latest" restart: "unless-stopped" volumes: - "./settings.json:/usr/src/api/config/settings.json" @@ -39,7 +39,7 @@ services: container_name: "xbs-reverse-proxy" depends_on: - "api" - image: "caddy:2.3.0-alpine" + image: "caddy:alpine" ports: - "443:443" - "80:80" diff --git a/dockerfile b/dockerfile index 10cd4b3..966330f 100644 --- a/dockerfile +++ b/dockerfile @@ -1,18 +1,22 @@ -FROM node:14.16.0-alpine +FROM node:fermium-alpine # Set environment variables -ENV XBROWSERSYNC_API_VERSION 1.1.13 WORKDIR /usr/src/api # Download release and unpack -RUN wget -q -O release.tar.gz https://github.com/xBrowserSync/api/archive/v$XBROWSERSYNC_API_VERSION.tar.gz \ +RUN apk update && apk add grep curl +RUN XBROWSERSYNC_API_VERSION="$(curl --silent "https://api.github.com/repos/xbrowsersync/api/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')" \ + && echo $XBROWSERSYNC_API_VERSION \ + && wget -q -O release.tar.gz https://github.com/xBrowserSync/api/archive/$XBROWSERSYNC_API_VERSION.tar.gz \ && tar -C . -xzf release.tar.gz \ && rm release.tar.gz \ + && XBROWSERSYNC_API_VERSION="${XBROWSERSYNC_API_VERSION:1}" \ && mv api-$XBROWSERSYNC_API_VERSION/* . \ && rm -rf api-$XBROWSERSYNC_API_VERSION/ # Install dependencies +RUN apk add python2 make RUN npm install --only=production # Expose port and start api From 12a25e1096165dc30abb26594c8bd3bfcfa69bd4 Mon Sep 17 00:00:00 2001 From: Luca Steccanella Date: Fri, 10 Dec 2021 15:12:07 +0100 Subject: [PATCH 7/7] Update dockerfile --- dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfile b/dockerfile index 966330f..23d149f 100644 --- a/dockerfile +++ b/dockerfile @@ -16,7 +16,7 @@ RUN XBROWSERSYNC_API_VERSION="$(curl --silent "https://api.github.com/repos/xbro && rm -rf api-$XBROWSERSYNC_API_VERSION/ # Install dependencies -RUN apk add python2 make +RUN apk add python2 python3 make RUN npm install --only=production # Expose port and start api