]> Untitled Git - lemmy.git/blob - docker/docker-compose.yml
Combine prod and dev docker setups using build-arg (#2739)
[lemmy.git] / docker / docker-compose.yml
1 version: "3.3"
2
3 networks:
4   # communication to web and clients
5   lemmyexternalproxy:
6   # communication between lemmy services
7   lemmyinternal:
8     driver: bridge
9     internal: true
10
11 services:
12   proxy:
13     image: nginx:1-alpine
14     networks:
15       - lemmyinternal
16       - lemmyexternalproxy
17     ports:
18     # actual and only port facing any connection from outside 
19       - "1236:1236"
20       - "8536:8536"
21     volumes:
22       - ./nginx.conf:/etc/nginx/nginx.conf:ro
23     restart: always
24     depends_on:
25       - pictrs
26       - lemmy-ui
27
28   lemmy:
29     # image: dessalines/lemmy:dev
30     # use this to build your local lemmy server image for development
31     # run docker compose up --build
32     build: 
33       context: ../
34       dockerfile: docker/Dockerfile
35       # args: 
36       #   RUST_RELEASE_MODE: release
37     # this hostname is used in nginx reverse proxy and also for lemmy ui to connect to the backend, do not change
38     hostname: lemmy
39     networks:
40       - lemmyinternal
41     restart: always
42     environment:
43       - RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug"
44       - RUST_BACKTRACE=full
45     volumes:
46       - ./lemmy.hjson:/config/config.hjson
47     depends_on:
48       - postgres
49       - pictrs
50
51   lemmy-ui:
52     image: dessalines/lemmy-ui:0.17.1
53     # use this to build your local lemmy ui image for development
54     # run docker compose up --build
55     # assuming lemmy-ui is cloned besides lemmy directory
56     # build: 
57     #  context: ../../../lemmy-ui
58     #  dockerfile: dev.dockerfile
59     networks:
60       - lemmyinternal
61     environment:
62       # this needs to match the hostname defined in the lemmy service
63       - LEMMY_UI_LEMMY_INTERNAL_HOST=lemmy:8536
64       # set the outside hostname here
65       - LEMMY_UI_LEMMY_EXTERNAL_HOST=localhost:1236
66       - LEMMY_HTTPS=false
67       - LEMMY_UI_DEBUG=true
68     depends_on:
69       - lemmy
70     restart: always
71
72   pictrs:
73     image: asonix/pictrs:0.3.1
74     # this needs to match the pictrs url in lemmy.hjson
75     hostname: pictrs
76     # we can set options to pictrs like this, here we set max. image size and forced format for conversion
77     # entrypoint: /sbin/tini -- /usr/local/bin/pict-rs -p /mnt -m 4 --image-format webp
78     networks:
79       - lemmyinternal
80     environment:
81       - PICTRS_OPENTELEMETRY_URL=http://otel:4137
82       - PICTRS__API_KEY=API_KEY
83       - RUST_LOG=debug
84       - RUST_BACKTRACE=full
85     user: 991:991
86     volumes:
87       - ./volumes/pictrs:/mnt
88     restart: always
89
90   postgres:
91     image: postgres:15-alpine
92     # this needs to match the database host in lemmy.hson
93     # Tune your settings via
94     # https://pgtune.leopard.in.ua/#/
95     # You can use this technique to add them here
96     # https://stackoverflow.com/a/30850095/1655478
97     hostname: postgres
98     command: [
99       "postgres",
100       "-c", "session_preload_libraries=auto_explain",
101       "-c", "auto_explain.log_min_duration=5ms",
102       "-c", "auto_explain.log_analyze=true"
103     ]
104     networks:
105       - lemmyinternal
106     # adding the external facing network to allow direct db access for devs
107       - lemmyexternalproxy
108     ports:
109     # use a different port so it doesnt conflict with potential postgres db running on the host
110       - "5433:5432"
111     environment:
112       - POSTGRES_USER=lemmy
113       - POSTGRES_PASSWORD=password
114       - POSTGRES_DB=lemmy
115     volumes:
116       - ./volumes/postgres:/var/lib/postgresql/data
117     restart: always
118
119   otel:
120     image: otel/opentelemetry-collector:latest
121     command: --config otel-local-config.yaml
122     networks:
123       - lemmyinternal
124       - lemmyexternalproxy
125     ports:
126       - "4317:4317"
127     volumes:
128       - type: bind
129         source: ./otel.yml
130         target: /otel-local-config.yaml
131     restart: unless-stopped
132     depends_on:
133       - jaeger
134   
135   jaeger:
136     image: jaegertracing/all-in-one:1
137     networks:
138       - lemmyinternal
139       - lemmyexternalproxy
140     ports:
141       - "14250:14250"
142       # To view traces, visit http://localhost:16686
143       - "16686:16686"
144     restart: unless-stopped