Skip to content

Commit fd9067b

Browse files
authored
518 setup env command (#519)
* Created command and cleaned * Simplified docker setup, created script to generate .env * add git ignore file back
1 parent 7888990 commit fd9067b

11 files changed

+226
-197
lines changed

.env.docker

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ FILESYSTEM_DRIVER=local
1212
BROADCAST_CONNECTION=log
1313
CACHE_STORE=redis
1414
QUEUE_CONNECTION=redis
15-
SESSION_DRIVER=file
15+
SESSION_DRIVER=redis
1616
SESSION_LIFETIME=120
1717

1818
MAIL_MAILER=log

README.md

+120-68
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<img src="https://github.com/JhumanJ/OpnForm/blob/main/public/img/social-preview.jpg?raw=true">
55
</p>
66

7-
87
<p align="center">
98
<a href="https://github.com/JhumanJ/OpnForm/stargazers"><img src="https://img.shields.io/github/stars/JhumanJ/OpnForm" alt="Github Stars"></a>
109
</a>
@@ -25,24 +24,25 @@
2524
2625
## Features
2726

28-
- No-code form builder, with infinite number of fields & submissions
29-
- Text inputs, Date inputs, URL inputs, Phone inputs, Email inputs, Checkboxes, Select and Multi-Select inputs, Number Inputs, Star-ratings, File uploads & more
30-
- Embed anywhere (on your website, in your Notion page, etc)
31-
- Email notifications (for both form owner & form respondents)
32-
- Hidden fields
33-
- Form passwords
34-
- URL form pre-fill
35-
- Slack integration
36-
- Webhooks
37-
- Form logic
38-
- Customize colors, add images or even some custom code
39-
- Captcha form protection
40-
- Form closing date
41-
- Limit the number of submissions allowed
27+
- No-code form builder, with infinite number of fields & submissions
28+
- Text inputs, Date inputs, URL inputs, Phone inputs, Email inputs, Checkboxes, Select and Multi-Select inputs, Number Inputs, Star-ratings, File uploads & more
29+
- Embed anywhere (on your website, in your Notion page, etc)
30+
- Email notifications (for both form owner & form respondents)
31+
- Hidden fields
32+
- Form passwords
33+
- URL form pre-fill
34+
- Slack integration
35+
- Webhooks
36+
- Form logic
37+
- Customize colors, add images or even some custom code
38+
- Captcha form protection
39+
- Form closing date
40+
- Limit the number of submissions allowed
4241

4342
And much more!
4443

4544
## Bounties
45+
4646
Get paid for contributing to OpnForm! Here are our open bounties:
4747

4848
<a href="https://console.algora.io/org/OpnForm/bounties?status=open">
@@ -60,98 +60,139 @@ It takes 1 minute to try out the builder for free. You'll have high availability
6060

6161
### Requirements
6262

63-
- PHP >= 8.0
64-
- MySQL/MariaDB or PostgreSQL
65-
- Node.js and NPM/Yarn/... to compile assets
63+
- PHP >= 8.0
64+
- MySQL/MariaDB or PostgreSQL
65+
- Node.js and NPM/Yarn/... to compile assets
6666

6767
## Installation
6868

69+
### Environment Setup
70+
71+
Before you can run the application, you need to set up the environment variables. We have provided a script that will automate the process of creating your `.env` files from the provided examples.
72+
73+
Follow these steps to set up your environment:
74+
75+
1. Make sure you have `openssl` installed, as it is required by the setup script to generate secure keys.
76+
77+
2. Run the setup script from the root of the project:
78+
79+
```bash
80+
chmod +x ./scripts/setup-env.sh
81+
./scripts/setup-env.sh
82+
```
83+
84+
**If you are using Docker** and want to prepare a Docker-specific environment, run the script with the `--docker` flag:
85+
86+
```bash
87+
./scripts/setup-env.sh --docker
88+
```
89+
90+
3. After running the script, review the `.env` and `client/.env` files to ensure all settings are correct for your environment.
91+
92+
Remember to never commit your `.env` files to version control. They should be kept private as they contain sensitive information.
93+
6994
### Docker Installation 🐳
7095

7196
OpnForm can be easily set up using Docker. Pre-built images are available on Docker Hub, which is the recommended method for most users.
7297

7398
#### Prerequisites
74-
- Docker
75-
- Docker Compose
99+
100+
- Docker
101+
- Docker Compose
76102

77103
#### Quick Start
78104

79105
1. Clone the repository:
80-
```
81-
git clone https://github.com/JhumanJ/OpnForm.git
82-
cd OpnForm
83-
```
84106

85-
2. Set up environment files:
86-
```
87-
cp .env.docker .env
88-
cp client/.env.docker client/.env
89-
```
107+
```
108+
git clone https://github.com/JhumanJ/OpnForm.git
109+
cd OpnForm
110+
```
111+
112+
2. Set up environment files by running the provided setup script. For detailed instructions, refer to the [Environment Setup](#environment-setup) section above:
113+
114+
```bash
115+
./scripts/setup-env.sh --docker
116+
```
90117

91118
3. Start the application:
92-
```
93-
docker-compose up -d
94-
```
119+
120+
```
121+
docker-compose up -d
122+
```
95123

96124
4. Access OpnForm at http://localhost
97125

98126
> 🌐 **Server Deployment Note**: When deploying to a server, configure the app URLs in both `.env` and `client/.env` files. Set `APP_URL` in `.env`, and both `NUXT_PUBLIC_APP_URL` & `NUXT_PUBLIC_API_BASE` in `client/.env`.
99127

100128
#### Customization
101129

102-
- **Environment Variables**: Modify `.env` and `client/.env` files to customize your setup. For example, to enable email features, configure a [supported mail driver](https://laravel.com/docs/11.x/mail) in the `.env` file.
130+
- **Environment Variables**: Modify `.env` and `client/.env` files to customize your setup. For example, to enable email features, configure a [supported mail driver](https://laravel.com/docs/11.x/mail) in the `.env` file.
103131

104132
#### Upgrading
105133

106134
1. Check the upgrade instructions for your target version in the documentation.
107135
2. Update your `docker-compose.yml` file if necessary.
108136
3. Apply changes:
109-
```
110-
docker-compose up -d
111-
```
137+
```
138+
docker-compose up -d
139+
```
112140

113-
### Initial Login
141+
#### Initial Login
114142

115143
After installation, use these credentials to access the admin panel:
116-
- Email: `admin@opnform.com`
117-
- Password: `password`
144+
145+
- Email: `admin@opnform.com`
146+
- Password: `password`
118147

119148
⚠️ Change these credentials immediately after your first login.
120149

121150
Note: Public registration is disabled in the self-hosted version. Use the admin account to invite additional users.
122151

123-
### Building from Source
152+
#### Building from Source
124153

125154
For development or customization, you can build the Docker images locally:
126155

127156
1. Build the images:
128-
```
129-
docker build -t opnform-ui:local -f docker/Dockerfile.client .
130-
docker build -t opnform-api:local -f docker/Dockerfile.api .
131-
```
157+
158+
```
159+
docker build -t opnform-ui:local -f docker/Dockerfile.client .
160+
docker build -t opnform-api:local -f docker/Dockerfile.api .
161+
```
132162

133163
2. Create a docker-compose override file:
134-
```
135-
cp docker-compose.override.yml.example docker-compose.override.yml
136-
```
137-
138-
Edit the `docker-compose.override.yml` file to use your locally built images:
139-
```yaml
140-
services:
141-
api:
142-
image: opnform-api:local
143-
ui:
144-
image: opnform-ui:local
145-
```
164+
165+
```
166+
cp docker-compose.override.yml.example docker-compose.override.yml
167+
```
168+
169+
Edit the `docker-compose.override.yml` file to use your locally built images:
170+
171+
```yaml
172+
services:
173+
api:
174+
image: opnform-api:local
175+
ui:
176+
image: opnform-ui:local
177+
```
146178

147179
3. Start the application:
148-
```
149-
docker-compose up -d
150-
```
180+
```
181+
docker-compose up -d
182+
```
151183

152184
This method allows you to make changes to the source code and rebuild the images as needed.
153185

186+
#### Clearing all resources
187+
188+
To completely remove all Docker containers, networks, and volumes created by `docker-compose` and also remove all images used by these services, you can use the following command:
189+
190+
```bash
191+
docker-compose down -v --rmi all
192+
```
193+
154194
### Using Laravel Valet
195+
155196
This section explains how to get started locally with the project. It's most likely relevant if you're trying to work on the project.
156197
First, let's work with the codebase and its dependencies.
157198
@@ -160,8 +201,8 @@ First, let's work with the codebase and its dependencies.
160201
git clone git@github.com:JhumanJ/OpnForm.git && cd OpnForm
161202
162203
# Install PHP dependencies
163-
composer install
164-
204+
composer install
205+
165206
# Install JS dependencies
166207
cd client && npm install
167208
@@ -183,9 +224,18 @@ php artisan jwt:secret # and select yes!
183224
# Creates DB schemas
184225
php artisan migrate
185226
```
186-
Now, create an S3 bucket (or equivalent). Create an IAM user with access to this bucket, fill the environment variables: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_DEFAULT_REGION`, `AWS_BUCKET`. In your AWS bucket permissions, add the following under "Cross-origin resource sharing (CORS)":
227+
228+
Now, create an S3 bucket (or equivalent). Create an IAM user with access to this bucket, fill the environment variables: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_DEFAULT_REGION`, `AWS_BUCKET`. In your AWS bucket permissions, add the following under "Cross-origin resource sharing (CORS)":
229+
187230
```json
188-
[ { "AllowedHeaders": [ "*" ], "AllowedMethods": [ "PUT", "POST", "GET", "DELETE" ], "AllowedOrigins": [ "*" ], "ExposeHeaders": [] } ]
231+
[
232+
{
233+
"AllowedHeaders": ["*"],
234+
"AllowedMethods": ["PUT", "POST", "GET", "DELETE"],
235+
"AllowedOrigins": ["*"],
236+
"ExposeHeaders": []
237+
}
238+
]
189239
```
190240
191241
🎉 Done! Enjoy your personal OpnForm instance at: [http://opnform.test](http://opnform.test).
@@ -197,14 +247,16 @@ Now, create an S3 bucket (or equivalent). Create an IAM user with access to this
197247
## Tech Stack
198248
199249
OpnForm is a standard web application built with:
200-
- [Laravel](https://laravel.com/) PHP framework
201-
- [NuxtJs](https://nuxt.com/) Front-end SSR framework
202-
- [Vue.js 3](https://vuejs.org/) Front-end framework
203-
- [TailwindCSS](https://tailwindcss.com/)
250+
251+
- [Laravel](https://laravel.com/) PHP framework
252+
- [NuxtJs](https://nuxt.com/) Front-end SSR framework
253+
- [Vue.js 3](https://vuejs.org/) Front-end framework
254+
- [TailwindCSS](https://tailwindcss.com/)
204255
205256
## Contribute
257+
206258
You're more than welcome to contribute to this project. We don't have guidelines on this yet, but we will soon. In the meantime, feel free to ask [any question here](https://github.com/JhumanJ/OpnForm/discussions).
207259
208260
## License
209-
OpnForm is open-source under the GNU Affero General Public License Version 3 (AGPLv3) or any later version. You can find it [here](https://github.com/JhumanJ/OpnForm/blob/main/LICENSE).
210261
262+
OpnForm is open-source under the GNU Affero General Public License Version 3 (AGPLv3) or any later version. You can find it [here](https://github.com/JhumanJ/OpnForm/blob/main/LICENSE).

client/.env.docker

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
NUXT_LOG_LEVEL=
22
NUXT_PUBLIC_APP_URL=/
33
NUXT_PUBLIC_API_BASE=/api
4-
NUXT_PRIVATE_API_BASE=http://localhost/api
4+
NUXT_PRIVATE_API_BASE=http://ingress/api
55
NUXT_PUBLIC_AI_FEATURES_ENABLED=false
66
NUXT_PUBLIC_AMPLITUDE_CODE=
77
NUXT_PUBLIC_CRISP_WEBSITE_ID=
@@ -10,5 +10,4 @@ NUXT_PUBLIC_ENV=local
1010
NUXT_PUBLIC_GOOGLE_ANALYTICS_CODE=
1111
NUXT_PUBLIC_H_CAPTCHA_SITE_KEY=
1212
NUXT_PUBLIC_PAID_PLANS_ENABLED=
13-
NUXT_PUBLIC_S3_ENABLED=false
14-
NUXT_API_SECRET=
13+
NUXT_PUBLIC_S3_ENABLED=false

docker-compose.yml

+3-7
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ services:
1010
DB_USERNAME: ${DB_USERNAME:-forge}
1111
DB_PASSWORD: ${DB_PASSWORD:-forge}
1212
DB_CONNECTION: ${DB_CONNECTION:-pgsql}
13-
LOG_LEVEL: ${LOG_LEVEL:-debug}
14-
LOG_CHANNEL: ${LOG_CHANNEL:-errorlog}
1513
AWS_ENDPOINT: http://minio:9000
1614
AWS_ACCESS_KEY_ID: ${MINIO_ACCESS_KEY:-minio}
1715
AWS_SECRET_ACCESS_KEY: ${MINIO_SECRET_KEY:-minio123}
@@ -23,11 +21,13 @@ services:
2321
env_file: ./.env
2422
volumes:
2523
- laravel-persist:/persist
26-
- secrets-config:/secrets
24+
- ./storage/logs:/usr/share/nginx/html/storage/logs
2725

2826
api-worker:
2927
<<: *api
3028
command: ./artisan queue:work
29+
volumes:
30+
- ./storage/logs:/usr/share/nginx/html/storage/logs
3131

3232
ui:
3333
image: jhumanj/opnform-client:latest
@@ -38,11 +38,8 @@ services:
3838
env_file:
3939
- ./client/.env
4040
volumes:
41-
- secrets-config:/secrets
4241
- ./client/.env:/app/.env
4342

44-
45-
4643
redis:
4744
image: redis:7
4845

@@ -65,4 +62,3 @@ services:
6562
volumes:
6663
laravel-persist:
6764
postgres-data:
68-
secrets-config:

docker/Dockerfile.api

-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ RUN chmod 777 -R storage
4040
RUN php artisan package:discover --ansi
4141

4242
COPY docker/php-fpm-entrypoint /usr/local/bin/opnform-entrypoint
43-
COPY docker/generate-api-secret.sh /usr/local/bin/
44-
RUN ln -s /secrets/api.env .env
4543

4644
RUN chmod a+x /usr/local/bin/*
4745

docker/Dockerfile.client

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ FROM node:20-alpine
2626
WORKDIR /app
2727
COPY --from=javascript-builder /app/.output/ /app/
2828
RUN ls /app/
29-
RUN ln -s /secrets/client.env .env
3029
ADD ./docker/node-entrypoint /entrypoint.sh
3130
RUN chmod a+x /entrypoint.sh
3231

0 commit comments

Comments
 (0)