Skip to content

Commit ec3fe18

Browse files
committed
add instructions to build a quick docker image for dev
1 parent 7571eb0 commit ec3fe18

File tree

4 files changed

+112
-0
lines changed

4 files changed

+112
-0
lines changed

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.git
2+
.gitignore
3+
Dockerfile*
4+
DockerFile*
5+
docker-compose*
6+
README.md
7+
LICENSE
8+
.vscode
9+

docker/DockerFile.dev

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# check docker/Readme.md
2+
3+
FROM ubuntu:impish
4+
RUN apt update
5+
RUN apt upgrade -y
6+
7+
RUN apt-get install -y locales && locale-gen en_US.UTF-8
8+
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
9+
10+
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt -y install curl build-essential libssl-dev pkg-config lsb-release
11+
RUN curl -so /etc/apt/trusted.gpg.d/oxen.gpg https://deb.oxen.io/pub.gpg
12+
RUN echo "deb https://deb.oxen.io $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/oxen.list
13+
RUN apt update
14+
RUN apt -y install python3-oxenmq python3-oxenc python3-pyonionreq python3-coloredlogs python3-uwsgidecorators python3-flask python3-cryptography python3-nacl python3-pil python3-protobuf python3-openssl python3-qrencode python3-better-profanity python3-sqlalchemy python3-sqlalchemy-utils uwsgi-plugin-python3
15+
16+
17+
# just add an alias to the pysogs-start command
18+
RUN echo -e '#!/bin/bash\nuwsgi docker/uwsgi-sogs-docker.ini' > /usr/bin/pysogs && \
19+
chmod +x /usr/bin/pysogs
20+
21+
22+
RUN mkdir session-pysogs
23+
WORKDIR session-pysogs
24+
25+
26+
EXPOSE 80

docker/Readme.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Docker for pysogs development
2+
3+
The file DockerFile.dev is specifically made for development if you are not running linux.
4+
It lets you create a docker running linux and the pysogs in it even if you are running Macos or Windows.
5+
It creates a docker container with the content of this git reposotiry mounted.
6+
Basically, whatever you edit in this repository will be represented on the docker container. So when you run the container, it will run your code.
7+
8+
## Build the container image
9+
10+
You need to have docker installed on your computer. Follow the docker documentation for your system first.
11+
Once you can run the hello world from github you should be fine
12+
13+
```
14+
docker run hello-world # this command should print "Hello from Docker!"
15+
16+
```
17+
18+
Then, build the container image for pysogs-dev as
19+
20+
```
21+
git clone [email protected]:oxen-io/session-pysogs.git
22+
cd session-pysogs
23+
sudo docker build . -f docker/DockerFile.dev -t pysogs-dev
24+
```
25+
26+
Before you can run the container you need to set the base config. You can do so by copying `sogs.ini.sample` to `sogs.ini` and replacing the line with base_url with `base_url = http://localhost`.
27+
28+
Next,
29+
You can run and attach to the container with
30+
31+
```
32+
sudo docker run -i -p 8080:80 -v $PWD:/session-pysogs -t pysogs-dev:latest
33+
```
34+
35+
To start the pysogs once you have a shell in the container do:
36+
37+
```
38+
pysogs
39+
```
40+
41+
To create a room once you have a shell inside the container do
42+
43+
```
44+
python3 -msogs --add-room fishing --name "Fish Talk"
45+
```
46+
47+
More doc at https://github.com/oxen-io/session-pysogs/blob/dev/administration.md#sogs-administration

docker/uwsgi-sogs-docker.ini

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# uwsgi configuration for listening directly on port 80; this is the simplest setup, but is less
2+
# flexible and slightly less performant than proxying through a front-end server (e.g. nginx) and
3+
# cannot be used if anything else on the system always wants to serve any HTTP traffic.
4+
#
5+
# Note that this configuration is meant for setups where sogs will be directly serving public HTTP
6+
# requests, and is sub-optimal for handling proxied requests; for that see the
7+
# uwsgi-sogs-proxied.ini configuration instead.
8+
9+
# Configuration requires:
10+
# - change the chdir= to the path where you want to write the sogs data files (database, uploads,
11+
# keys, etc.)
12+
#
13+
# - change uid= and gid= values to the system user/group names that the script should run as. DO
14+
# NOT RUN AS root! That path that you specify for `chdir=` should be owned by this user/group.
15+
#
16+
# - tweak the `processes` argument, if desired and you have more than 2 cores and expect a very busy
17+
# SOGS.
18+
#
19+
# - if using uwsgi in vassal mode then put the configuration file into /etc/uwsgi/vassals
20+
#
21+
[uwsgi]
22+
chdir = /session-pysogs
23+
uid = root
24+
gid = root
25+
plugins = python3,http
26+
processes = 2
27+
enable-threads = true
28+
http = :80
29+
mount = /=sogs.web:app
30+
mule = sogs.mule:run

0 commit comments

Comments
 (0)