Metastem / wikiless

A free open source alternative Wikipedia front-end focused on privacy.
https://wikiless.metastem.su/
GNU Affero General Public License v3.0
175 stars 19 forks source link

Update Dockerfile #45

Closed twomoses closed 1 year ago

twomoses commented 1 year ago

Reverting to an older version of Dockerfile, but copying the new wikiless.config into the container as config.js to correct #43.

okteto-cloud[bot] commented 1 year ago

Preview environment metastem-wikiless-pr-45 is being deployed...

twomoses commented 1 year ago

So, the docker-compose file has image: wikiless:latest which doesn't even exist, preventing docker-compose up -d from working out of the box. If you pull ghcr.io/metastem/wikiless:latest which was previously configured, it fails miserably. I didn't add that to the PR thinking maybe that was removed because it will not longer be updated? Furthermore, I see no commits made after issue #43 was reported, an issue I was able to replicate on 4 machines on our network.

twomoses commented 1 year ago

The fact that you have all that built from cache in your screen shot says a lot. You should run docker system prune -a and try again. I can get a successful build, but the run fails instantly.

# docker compose up -d
[+] Running 7/7
 ✔ wikiless_redis 6 layers [⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                                                                                                                                               2.0s 
   ✔ 8a49fdb3b6a5 Pull complete                                                                                                                                                                                                          0.7s 
   ✔ 2121af5b35c8 Pull complete                                                                                                                                                                                                          0.7s 
   ✔ 13ce36f68149 Pull complete                                                                                                                                                                                                          0.9s 
   ✔ d0786890719f Pull complete                                                                                                                                                                                                          1.1s 
   ✔ e0001f8e7e31 Pull complete                                                                                                                                                                                                          1.1s 
   ✔ 4ea079d1c234 Pull complete                                                                                                                                                                                                          1.1s 
[+] Building 8.5s (10/10) FINISHED                                                                                                                                                                                                            
 => [wikiless internal] load build definition from Dockerfile                                                                                                                                                                            0.0s
 => => transferring dockerfile: 220B                                                                                                                                                                                                     0.0s
 => [wikiless internal] load .dockerignore                                                                                                                                                                                               0.0s
 => => transferring context: 65B                                                                                                                                                                                                         0.0s
 => [wikiless internal] load metadata for docker.io/library/node:16-alpine                                                                                                                                                               0.5s
 => [wikiless 1/6] FROM docker.io/library/node:16-alpine@sha256:bca38851a77922e849907c57588bdf3dfcf95725186d7c26cdfd64da730989d3                                                                                                         1.6s
 => => resolve docker.io/library/node:16-alpine@sha256:bca38851a77922e849907c57588bdf3dfcf95725186d7c26cdfd64da730989d3                                                                                                                  0.0s
 => => sha256:95f54ffb5ed5d7ebd8c79e1e394e8b740ced9176efc851047c79d1493d0a0330 6.73kB / 6.73kB                                                                                                                                           0.0s
 => => sha256:81a876a26187c48374eaf51a3efda1294469e66381810084c2b8c101c005e38a 36.63MB / 36.63MB                                                                                                                                         0.7s
 => => sha256:bc31d7640bebc025f45de839ddfff153be28a7512434c6b1651a6087bc1a9a97 2.34MB / 2.34MB                                                                                                                                           0.3s
 => => sha256:8f48a6f22e2bf6fc68cfe55a5b2f5aab60777f06d766e07f75c1b12c4d1ad22f 451B / 451B                                                                                                                                               0.2s
 => => sha256:bca38851a77922e849907c57588bdf3dfcf95725186d7c26cdfd64da730989d3 1.43kB / 1.43kB                                                                                                                                           0.0s
 => => sha256:027c23b7fdf50a333d2bc9e9b655f42746602bf528cf33c5cb78a653b7da2d29 1.16kB / 1.16kB                                                                                                                                           0.0s
 => => extracting sha256:81a876a26187c48374eaf51a3efda1294469e66381810084c2b8c101c005e38a                                                                                                                                                0.8s
 => => extracting sha256:bc31d7640bebc025f45de839ddfff153be28a7512434c6b1651a6087bc1a9a97                                                                                                                                                0.0s
 => => extracting sha256:8f48a6f22e2bf6fc68cfe55a5b2f5aab60777f06d766e07f75c1b12c4d1ad22f                                                                                                                                                0.0s
 => [wikiless 2/6] RUN apk add git                                                                                                                                                                                                       1.9s
 => [wikiless 3/6] RUN git clone https://github.com/Metastem/wikiless.git /wikiless                                                                                                                                                      0.9s
 => [wikiless 4/6] WORKDIR /wikiless                                                                                                                                                                                                     0.0s 
 => [wikiless 5/6] RUN apk add redis                                                                                                                                                                                                     1.0s 
 => [wikiless 6/6] RUN npm install --no-optional                                                                                                                                                                                         2.3s 
 => [wikiless] exporting to image                                                                                                                                                                                                        0.2s 
 => => exporting layers                                                                                                                                                                                                                  0.2s 
 => => writing image sha256:c7ac26e9a257b6657e4c37a165b92fea45a76d24bb56dbc16d84d9e4155c1ddc                                                                                                                                             0.0s 
 => => naming to docker.io/library/wikiless-wikiless                                                                                                                                                                                     0.0s 
[+] Running 3/3
 ✔ Network wikiless_wikiless_net        Created                                                                                                                                                                                          0.0s 
 ✔ Container wikiless-wikiless_redis-1  Started                                                                                                                                                                                          0.3s 
 ✔ Container wikiless-wikiless-1        Started                                                                                                                                                                                          0.6s 
# docker logs -f wikiless-wikiless-1

> Wikiless@0.1.1 start
> node src/wikiless.js

node:internal/modules/cjs/loader:1029
  throw err;
  ^

Error: Cannot find module '../config'
Require stack:
- /wikiless/src/wikiless.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1026:15)
    at Function.Module._load (node:internal/modules/cjs/loader:871:27)
    at Module.require (node:internal/modules/cjs/loader:1098:19)
    at require (node:internal/modules/cjs/helpers:108:18)
    at Object.<anonymous> (/wikiless/src/wikiless.js:1:16)
    at Module._compile (node:internal/modules/cjs/loader:1196:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
    at Module.load (node:internal/modules/cjs/loader:1074:32)
    at Function.Module._load (node:internal/modules/cjs/loader:909:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/wikiless/src/wikiless.js' ]
}
twomoses commented 1 year ago

Now, if I delete everything and run my fork, switch the compose file from the image to build, and run docker-compose up -d, it comes up and works like a charm. Feel free to deny this PR if you find otherwise.

~# git clone https://github.com/twomoses/wikiless.git
Cloning into 'wikiless'...
remote: Enumerating objects: 881, done.
remote: Counting objects: 100% (194/194), done.
remote: Compressing objects: 100% (127/127), done.
remote: Total 881 (delta 91), reused 124 (delta 60), pack-reused 687
Receiving objects: 100% (881/881), 435.40 KiB | 1.04 MiB/s, done.
Resolving deltas: 100% (490/490), done.

~# cd wikiless/

~/wikiless# nano docker-compose.yml 

~/wikiless# docker compose up -d
[+] Running 7/7
 ✔ wikiless_redis 6 layers [⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                                                                                                                                               2.0s 
   ✔ 8a49fdb3b6a5 Pull complete                                                                                                                                                                                                          0.7s 
   ✔ 2121af5b35c8 Pull complete                                                                                                                                                                                                          0.7s 
   ✔ 13ce36f68149 Pull complete                                                                                                                                                                                                          0.8s 
   ✔ d0786890719f Pull complete                                                                                                                                                                                                          1.1s 
   ✔ e0001f8e7e31 Pull complete                                                                                                                                                                                                          1.1s 
   ✔ 4ea079d1c234 Pull complete                                                                                                                                                                                                          1.1s 
[+] Building 6.4s (15/15) FINISHED                                                                                                                                                                                                            
 => [wikiless internal] load build definition from Dockerfile                                                                                                                                                                            0.0s
 => => transferring dockerfile: 278B                                                                                                                                                                                                     0.0s
 => [wikiless internal] load .dockerignore                                                                                                                                                                                               0.0s
 => => transferring context: 65B                                                                                                                                                                                                         0.0s
 => [wikiless internal] load metadata for gcr.io/distroless/nodejs:16                                                                                                                                                                    0.9s
 => [wikiless internal] load metadata for docker.io/library/node:16-alpine                                                                                                                                                               0.8s
 => [wikiless auth] library/node:pull token for registry-1.docker.io                                                                                                                                                                     0.0s
 => [wikiless build 1/4] FROM docker.io/library/node:16-alpine@sha256:bca38851a77922e849907c57588bdf3dfcf95725186d7c26cdfd64da730989d3                                                                                                   2.7s
 => => resolve docker.io/library/node:16-alpine@sha256:bca38851a77922e849907c57588bdf3dfcf95725186d7c26cdfd64da730989d3                                                                                                                  0.0s
 => => sha256:bca38851a77922e849907c57588bdf3dfcf95725186d7c26cdfd64da730989d3 1.43kB / 1.43kB                                                                                                                                           0.0s
 => => sha256:027c23b7fdf50a333d2bc9e9b655f42746602bf528cf33c5cb78a653b7da2d29 1.16kB / 1.16kB                                                                                                                                           0.0s
 => => sha256:95f54ffb5ed5d7ebd8c79e1e394e8b740ced9176efc851047c79d1493d0a0330 6.73kB / 6.73kB                                                                                                                                           0.0s
 => => sha256:81a876a26187c48374eaf51a3efda1294469e66381810084c2b8c101c005e38a 36.63MB / 36.63MB                                                                                                                                         5.5s
 => => sha256:bc31d7640bebc025f45de839ddfff153be28a7512434c6b1651a6087bc1a9a97 2.34MB / 2.34MB                                                                                                                                           1.6s
 => => sha256:8f48a6f22e2bf6fc68cfe55a5b2f5aab60777f06d766e07f75c1b12c4d1ad22f 451B / 451B                                                                                                                                               1.6s
 => => extracting sha256:81a876a26187c48374eaf51a3efda1294469e66381810084c2b8c101c005e38a                                                                                                                                                0.7s
 => => extracting sha256:bc31d7640bebc025f45de839ddfff153be28a7512434c6b1651a6087bc1a9a97                                                                                                                                                0.0s
 => => extracting sha256:8f48a6f22e2bf6fc68cfe55a5b2f5aab60777f06d766e07f75c1b12c4d1ad22f                                                                                                                                                0.0s
 => [wikiless internal] load build context                                                                                                                                                                                               0.0s
 => => transferring context: 1.19MB                                                                                                                                                                                                      0.0s
 => [wikiless stage-1 1/4] FROM gcr.io/distroless/nodejs:16@sha256:0f7fbe2f3853fd719204ff417dda421eea2f8db8e17875820fddac5d3a8f572c                                                                                                      1.8s
 => => resolve gcr.io/distroless/nodejs:16@sha256:0f7fbe2f3853fd719204ff417dda421eea2f8db8e17875820fddac5d3a8f572c                                                                                                                       0.0s
 => => sha256:0f7fbe2f3853fd719204ff417dda421eea2f8db8e17875820fddac5d3a8f572c 741B / 741B                                                                                                                                               0.0s
 => => sha256:dd935e4985065176e806932474759ee82ad580f649cf7fe791632c5bbc1766ca 918B / 918B                                                                                                                                               0.0s
 => => sha256:a5a8ba5ebae9ff6a68d4897ad0b52ea1585ac8b2b53ede7607867cfb3edc9ed8 967B / 967B                                                                                                                                               0.0s
 => => sha256:383e1c5dd0c1830143b1230e90292ebd4219911e0512b70d250c8907c4899110 821.00kB / 821.00kB                                                                                                                                       0.3s
 => => sha256:c59673e9fae3f9d588110a25acdf7240f3a5d97c40fb86ccc71c23bf7abbea53 8.02MB / 8.02MB                                                                                                                                           0.7s
 => => sha256:7dcffaf987694bb0a0863ae2c3b582125b1c20d3148f0412f901b918b9a8e22d 817.61kB / 817.61kB                                                                                                                                       0.5s
 => => extracting sha256:383e1c5dd0c1830143b1230e90292ebd4219911e0512b70d250c8907c4899110                                                                                                                                                0.1s
 => => sha256:9cec46870c178ccc4225033fe98f8b6de5bbb8b01a0ead80ac97acc076605424 32.00MB / 32.00MB                                                                                                                                         1.3s
 => => extracting sha256:c59673e9fae3f9d588110a25acdf7240f3a5d97c40fb86ccc71c23bf7abbea53                                                                                                                                                0.1s
 => => extracting sha256:7dcffaf987694bb0a0863ae2c3b582125b1c20d3148f0412f901b918b9a8e22d                                                                                                                                                0.0s
 => => extracting sha256:9cec46870c178ccc4225033fe98f8b6de5bbb8b01a0ead80ac97acc076605424                                                                                                                                                0.5s
 => [wikiless build 2/4] WORKDIR /wikiless                                                                                                                                                                                               0.2s
 => [wikiless build 3/4] COPY . /wikiless                                                                                                                                                                                                0.0s
 => [wikiless build 4/4] RUN npm install --no-optional                                                                                                                                                                                   2.1s
 => [wikiless stage-1 2/4] COPY --from=build /wikiless /wikiless                                                                                                                                                                         0.1s 
 => [wikiless stage-1 3/4] WORKDIR /wikiless                                                                                                                                                                                             0.0s 
 => [wikiless stage-1 4/4] COPY wikiless.config config.js                                                                                                                                                                                0.0s 
 => [wikiless] exporting to image                                                                                                                                                                                                        0.1s 
 => => exporting layers                                                                                                                                                                                                                  0.1s
 => => writing image sha256:f6846d80123a5754591d0597a8662570bf90ffa2dfd85b6185089f7a52e2932d                                                                                                                                             0.0s
 => => naming to docker.io/library/wikiless-wikiless                                                                                                                                                                                     0.0s
[+] Running 3/3
 ✔ Network wikiless_wikiless_net        Created                                                                                                                                                                                          0.0s 
 ✔ Container wikiless-wikiless_redis-1  Started                                                                                                                                                                                          0.3s 
 ✔ Container wikiless-wikiless-1        Started                                                                                                                                                                                          0.5s 

~/wikiless# docker logs -f wikiless-wikiless-1
Wikiless changethis running on http://0.0.0.0:8080
Cleared cached static media files. You can turn this off by setting the config.cache_control to false.
Fetched url https://en.wikipedia.org/?useskin=vector&useskin=vector from Wikipedia.
twomoses commented 1 year ago

Okay, since I host web apps in several regions around the world, allow me to hold your hand through this:

  1. Drop the current deployment.
    root@host:~/wikiless# docker compose down
    [+] Running 3/3
    ✔ Container wikiless-wikiless-1        Removed     0.0s 
    ✔ Container wikiless-wikiless_redis-1  Removed     0.4s 
    ✔ Network wikiless_wikiless_net        Removed     0.1s 
  2. Remove the current code and clean the environment:
    
    root@host:~/wikiless# cd ..
    root@host:~# rm -rf wikiless/
    root@host:~# docker system prune -af
    Deleted Images:
    untagged: wikiless-wikiless:latest
    deleted: sha256:bfbbda20fb79ad8e23aafa4e15d63fffee8c7ad059a1f8b100ad0948f14d4926
    untagged: redis:alpine
    untagged: redis@sha256:1f27b9eb680ffcf6c68966c0d5f578bb1b030ca7cd8ec4e758c429e7f72005a0
    deleted: sha256:f37f9f678836efb038d6368daa868cc4a88c127f919e73dc8904fcb1c5308eae
    deleted: sha256:65105cae2424331ca986f099936440840f5ccb2cca4d933e95b31bf971cc8388
    deleted: sha256:c42f0c92b315f752e0954bd5ba2a10117001dce3aa7749e967469c780ae16042
    deleted: sha256:6a381eb65020bd7721e104caed90f705b86bd7b85990051e7f902cfa4890d62c
    deleted: sha256:c57386ae9ce65c2319b4be4ddd3cb69909e1aba8197be6ceb2bc5ee344721a62
    deleted: sha256:b7a42fa5eeb52490970bfc31ff60a4fe3b06b619fee1652633cbe08f114f6dae

Deleted build cache objects: jpngm5cuyktolfjiw0b0r9b0x v8746ano4k793j9vhw30wtmz8 fs8arquffn7p6r77ome186k0q qrjxle2aeh91uxhp8tkurgilo bvkc2iijc0pgnpai6azkgk8xh pflrgd1fbl1lcskp46ft73um8 u4vxixh7368ao1jp2unlc7c47 u75z144nsb87ueq86y5guqmt5 ptp831ozw954tq5jd473jmu0r 2oj7gtvhegfa26t14wdtyp60f zpf2m87wtdoozwxl0q1ei69n2

Total reclaimed space: 49.37MB

3. Pull the latest code: 

root@host:~# git clone https://github.com/Metastem/wikiless.git Cloning into 'wikiless'... remote: Enumerating objects: 872, done. remote: Counting objects: 100% (185/185), done. remote: Compressing objects: 100% (118/118), done. remote: Total 872 (delta 86), reused 126 (delta 60), pack-reused 687 Receiving objects: 100% (872/872), 433.58 KiB | 3.52 MiB/s, done. Resolving deltas: 100% (485/485), done. root@host:~# cd wikiless/

4. Add proposed changes from #46: 

root@host:~/wikiless# nano docker-compose.yml root@host:~/wikiless# cat docker-compose.yml version: "3.9"

services: wikiless:

build from source

build: .
#image: wikiless:latest
restart: always
networks:
  wikiless_net:
    ipv4_address: 172.4.0.6
environment:
  THEME: dark  # change to light if you do not want dark by default
  HTTP_ADDR: 0.0.0.0 # don't touch
  DEFAULT_LANG: en # change to any language you want
  DOMAIN: changethis # set this to your domain do not add http://
  WIKIPAGE_CACHE_EXPIRATION: 3600
  wikimedia_useragent: Wikiless media proxy bot (https://github.com/Metastem/wikiless) 
ports:
  - "127.0.0.1:8180:8080" # change port if needed
read_only: true
security_opt:
  - no-new-privileges:true
cap_drop:
  - ALL
depends_on:
    - wikiless_redis

wikiless_redis: image: "redis:alpine" restart: always networks: wikiless_net: ipv4_address: 172.4.0.5 ports:

networks: wikiless_net: ipam: config:

Wikiless@0.1.1 start node src/wikiless.js

node:internal/modules/cjs/loader:1029 throw err; ^

Error: Cannot find module '../config' Require stack:

Wikiless@0.1.1 start node src/wikiless.js

node:internal/modules/cjs/loader:1029 throw err; ^

Error: Cannot find module '../config' Require stack:

Wikiless@0.1.1 start node src/wikiless.js

node:internal/modules/cjs/loader:1029 throw err; ^

Error: Cannot find module '../config' Require stack:

Wikiless@0.1.1 start node src/wikiless.js

node:internal/modules/cjs/loader:1029 throw err; ^

Error: Cannot find module '../config' Require stack:

Wikiless@0.1.1 start node src/wikiless.js

node:internal/modules/cjs/loader:1029 throw err; ^

Error: Cannot find module '../config' Require stack:

Wikiless@0.1.1 start node src/wikiless.js

node:internal/modules/cjs/loader:1029 throw err; ^

Error: Cannot find module '../config' Require stack:

Wikiless@0.1.1 start node src/wikiless.js

node:internal/modules/cjs/loader:1029 throw err; ^

Error: Cannot find module '../config' Require stack:

twomoses commented 1 year ago

Bro please learn more about self-hosting, I tested it and it works fine lol.

Make sure you know the main docker-compose settings

In the spirit of "learn more about self-hosting", please consider the following:

  1. You've assumed my gender. I don't really care, but it's Pride Month, and a lot of people do care. Communities are made up of people, ya know?
  2. You've opened multiple PR's to address everything that this PR addresses.
  3. The image you create with your PR's is 23% larger than the one this PR introduces, and the size increase does not seem to be necessary.
  4. You've now obscured the ability to configure environment variables within the docker file in the latest commit on #46. You can have both, ya know?

I don't care what gets merged as long as the issue gets fixed, but I wanted to offer some enlightened thought for consideration.

twomoses commented 1 year ago

Oh, also, the original intent was that the image be built with config.js included and pushed to Docker Hub. Self-hosters would pull the image and override what was configured there with the environment variables. That's why the default was to pull wikiless:latest and set those variables.