Skip to content

Commit 478a7eb

Browse files
authored
Merge pull request #1 from froxlor/fix/refactoring
Refator stunnel and docs; merge environment variables
2 parents 8d7a6f5 + 4b21ac2 commit 478a7eb

8 files changed

Lines changed: 381 additions & 102 deletions

File tree

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[docker-compose.yml]
18+
indent_size = 4

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/.idea
22
/database
3+
/froxlor
34
/redis
45
.env
56
docker-compose.yml
6-
froxlor.env
7+
froxlor.env

DEVELOPERS.md

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# Developer Guide
2+
3+
This guide describes how to set up a local development environment for the froxlor container and how to mount
4+
additional packages during development.
5+
6+
## Directory Structure
7+
8+
A typical local development setup may look like this:
9+
10+
```text
11+
.
12+
├── container
13+
├── froxlor
14+
├── framework
15+
└── example-package
16+
```
17+
18+
In this layout:
19+
20+
* `container` contains the Docker setup.
21+
* `froxlor` contains the froxlor application.
22+
* `framework` contains the froxlor framework package.
23+
* `example-package` contains an additional package under development.
24+
25+
## Docker Compose
26+
27+
The following `docker-compose.yml` example can be used for local development.
28+
29+
```yaml
30+
services:
31+
froxlor:
32+
image: hub.froxlor.io/froxlor/froxlor:latest
33+
build: .
34+
restart: unless-stopped
35+
privileged: true
36+
pid: "host"
37+
depends_on:
38+
db:
39+
condition: service_healthy
40+
redis:
41+
condition: service_healthy
42+
adminer:
43+
condition: service_started
44+
ports:
45+
- "8000:8000"
46+
# Use the environment and/or the env_file as you like
47+
environment:
48+
FROXLOR_DB_CONNECTION: mariadb
49+
FROXLOR_DB_HOST: db
50+
FROXLOR_DB_PORT: 3306
51+
FROXLOR_DB_DATABASE: froxlor
52+
FROXLOR_DB_USERNAME: froxlor
53+
FROXLOR_DB_PASSWORD: CHANGEM3
54+
env_file:
55+
- path: ../froxlor/.env
56+
required: false
57+
volumes:
58+
- ../froxlor:/var/www/html/froxlor
59+
- ../framework:/opt/froxlor/packages/framework
60+
db:
61+
image: mariadb:latest
62+
restart: unless-stopped
63+
environment:
64+
MARIADB_ROOT_PASSWORD: CHANGEM3
65+
MARIADB_DATABASE: froxlor
66+
MARIADB_USER: froxlor
67+
MARIADB_PASSWORD: CHANGEM3
68+
healthcheck:
69+
test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ]
70+
start_period: 30s
71+
interval: 10s
72+
timeout: 5s
73+
retries: 5
74+
volumes:
75+
- database:/var/lib/mysql
76+
redis:
77+
image: redis:latest
78+
restart: unless-stopped
79+
healthcheck:
80+
test: [ "CMD", "redis-cli", "ping" ]
81+
start_period: 5s
82+
interval: 10s
83+
timeout: 5s
84+
retries: 5
85+
volumes:
86+
- redis:/data
87+
adminer:
88+
image: adminer:latest
89+
restart: unless-stopped
90+
ports:
91+
- "8080:8080"
92+
depends_on:
93+
- db
94+
volumes:
95+
database:
96+
redis:
97+
```
98+
99+
> [!WARNING]
100+
> This development setup runs the froxlor container in privileged mode and uses the host PID namespace. Use this
101+
> configuration only in trusted local development environments.
102+
103+
## Start the Development Environment
104+
105+
Start all services with:
106+
107+
```bash
108+
docker compose up -d
109+
```
110+
111+
After the services have started, open froxlor in your browser:
112+
113+
```text
114+
http://localhost:8000
115+
```
116+
117+
Adminer is available at:
118+
119+
```text
120+
http://localhost:8080
121+
```
122+
123+
## Package Development
124+
125+
Additional packages can be mounted into the container under `/opt/froxlor/packages`.
126+
127+
For example, to develop an additional package named `example-package`, add it as a volume:
128+
129+
```yaml
130+
services:
131+
froxlor:
132+
# ...
133+
environment:
134+
FROXLOR_DEV_REPOSITORIES: framework,example-package
135+
FROXLOR_DEV_PACKAGES: froxlor/example-package
136+
volumes:
137+
- ../froxlor:/var/www/html/froxlor
138+
- ../framework:/opt/froxlor/packages/framework
139+
- ../example-package:/opt/froxlor/packages/example-package
140+
```
141+
142+
## Helpful Commands
143+
144+
Here you'll find a list of helpful commands that you might need to use sometimes because of certain edge cases.
145+
146+
### Database migration and seeding
147+
148+
If you mount the source code without an existing database, startup may fail because database initialization will not
149+
run when the source code is present. To migrate and seed the database, run the following command:
150+
151+
```shell
152+
docker compose run froxlor php artisan migrate:fresh --seed
153+
```
154+
155+
### Usage of Composer
156+
157+
Sometimes you may wish to use Composer without using froxlor's package management. This can easily be done with the
158+
following command:
159+
160+
```shell
161+
docker compose run froxlor composer <...>
162+
```

Dockerfile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
FROM hub.froxlor.io/laravel/container:8.5-octane-minimal
22

3-
LABEL maintainer="froxlor team <team@froxlor.org>"
3+
LABEL maintainer="froxlor Team <team@froxlor.org>"
44
LABEL org.opencontainers.image.title="froxlor Container"
55
LABEL org.opencontainers.image.description="froxlor container image for Docker, Kubernetes, and other container platforms."
66
LABEL org.opencontainers.image.source=https://github.com/froxlor/container
77
LABEL org.opencontainers.image.licenses=LGPL-2.1-only
88

99
# Set working directory inside container
10+
RUN git config --global --add safe.directory /var/www/html/froxlor
1011
WORKDIR /var/www/html/froxlor
1112

1213
# Install openssl and stunnel for SSL termination
1314
RUN apk add --no-cache openssl stunnel
1415

15-
# Expose ports
16-
EXPOSE 8443
16+
# Copy scripts
17+
COPY bin/ /opt/froxlor/bin/
1718

18-
# Copy the entrypoint script
19+
# Copy entrypoint script
1920
COPY entrypoint.sh /entrypoint.sh
2021
RUN chmod +x /entrypoint.sh
2122

2223
# Set entrypoint
2324
ENTRYPOINT ["/entrypoint.sh"]
2425

26+
# Expose ports
27+
EXPOSE 8000
28+
EXPOSE 8443
29+
2530
# Default command to run froxlor server
2631
CMD ["composer", "run", "serve"]

0 commit comments

Comments
 (0)