Skip to content

Commit

Permalink
518 setup env command (#519)
Browse files Browse the repository at this point in the history
* Created command and cleaned

* Simplified docker setup, created script to generate .env

* add git ignore file back
  • Loading branch information
JhumanJ authored Aug 8, 2024
1 parent 7888990 commit fd9067b
Show file tree
Hide file tree
Showing 11 changed files with 226 additions and 197 deletions.
2 changes: 1 addition & 1 deletion .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ FILESYSTEM_DRIVER=local
BROADCAST_CONNECTION=log
CACHE_STORE=redis
QUEUE_CONNECTION=redis
SESSION_DRIVER=file
SESSION_DRIVER=redis
SESSION_LIFETIME=120

MAIL_MAILER=log
Expand Down
188 changes: 120 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<img src="https://github.com/JhumanJ/OpnForm/blob/main/public/img/social-preview.jpg?raw=true">
</p>


<p align="center">
<a href="https://github.com/JhumanJ/OpnForm/stargazers"><img src="https://img.shields.io/github/stars/JhumanJ/OpnForm" alt="Github Stars"></a>
</a>
Expand All @@ -25,24 +24,25 @@
## Features

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

And much more!

## Bounties

Get paid for contributing to OpnForm! Here are our open bounties:

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

### Requirements

- PHP >= 8.0
- MySQL/MariaDB or PostgreSQL
- Node.js and NPM/Yarn/... to compile assets
- PHP >= 8.0
- MySQL/MariaDB or PostgreSQL
- Node.js and NPM/Yarn/... to compile assets

## Installation

### Environment Setup

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.

Follow these steps to set up your environment:

1. Make sure you have `openssl` installed, as it is required by the setup script to generate secure keys.

2. Run the setup script from the root of the project:

```bash
chmod +x ./scripts/setup-env.sh
./scripts/setup-env.sh
```

**If you are using Docker** and want to prepare a Docker-specific environment, run the script with the `--docker` flag:

```bash
./scripts/setup-env.sh --docker
```

3. After running the script, review the `.env` and `client/.env` files to ensure all settings are correct for your environment.

Remember to never commit your `.env` files to version control. They should be kept private as they contain sensitive information.

### Docker Installation 🐳

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

#### Prerequisites
- Docker
- Docker Compose

- Docker
- Docker Compose

#### Quick Start

1. Clone the repository:
```
git clone https://github.com/JhumanJ/OpnForm.git
cd OpnForm
```

2. Set up environment files:
```
cp .env.docker .env
cp client/.env.docker client/.env
```
```
git clone https://github.com/JhumanJ/OpnForm.git
cd OpnForm
```

2. Set up environment files by running the provided setup script. For detailed instructions, refer to the [Environment Setup](#environment-setup) section above:

```bash
./scripts/setup-env.sh --docker
```

3. Start the application:
```
docker-compose up -d
```

```
docker-compose up -d
```

4. Access OpnForm at http://localhost

> 🌐 **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`.

#### Customization

- **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.
- **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.

#### Upgrading

1. Check the upgrade instructions for your target version in the documentation.
2. Update your `docker-compose.yml` file if necessary.
3. Apply changes:
```
docker-compose up -d
```
```
docker-compose up -d
```

### Initial Login
#### Initial Login

After installation, use these credentials to access the admin panel:
- Email: `[email protected]`
- Password: `password`

- Email: `[email protected]`
- Password: `password`

⚠️ Change these credentials immediately after your first login.

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

### Building from Source
#### Building from Source

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

1. Build the images:
```
docker build -t opnform-ui:local -f docker/Dockerfile.client .
docker build -t opnform-api:local -f docker/Dockerfile.api .
```

```
docker build -t opnform-ui:local -f docker/Dockerfile.client .
docker build -t opnform-api:local -f docker/Dockerfile.api .
```

2. Create a docker-compose override file:
```
cp docker-compose.override.yml.example docker-compose.override.yml
```

Edit the `docker-compose.override.yml` file to use your locally built images:
```yaml
services:
api:
image: opnform-api:local
ui:
image: opnform-ui:local
```

```
cp docker-compose.override.yml.example docker-compose.override.yml
```

Edit the `docker-compose.override.yml` file to use your locally built images:

```yaml
services:
api:
image: opnform-api:local
ui:
image: opnform-ui:local
```

3. Start the application:
```
docker-compose up -d
```
```
docker-compose up -d
```

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

#### Clearing all resources

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:

```bash
docker-compose down -v --rmi all
```

### Using Laravel Valet

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.
First, let's work with the codebase and its dependencies.
Expand All @@ -160,8 +201,8 @@ First, let's work with the codebase and its dependencies.
git clone [email protected]:JhumanJ/OpnForm.git && cd OpnForm
# Install PHP dependencies
composer install
composer install
# Install JS dependencies
cd client && npm install
Expand All @@ -183,9 +224,18 @@ php artisan jwt:secret # and select yes!
# Creates DB schemas
php artisan migrate
```
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)":
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)":
```json
[ { "AllowedHeaders": [ "*" ], "AllowedMethods": [ "PUT", "POST", "GET", "DELETE" ], "AllowedOrigins": [ "*" ], "ExposeHeaders": [] } ]
[
{
"AllowedHeaders": ["*"],
"AllowedMethods": ["PUT", "POST", "GET", "DELETE"],
"AllowedOrigins": ["*"],
"ExposeHeaders": []
}
]
```
🎉 Done! Enjoy your personal OpnForm instance at: [http://opnform.test](http://opnform.test).
Expand All @@ -197,14 +247,16 @@ Now, create an S3 bucket (or equivalent). Create an IAM user with access to this
## Tech Stack
OpnForm is a standard web application built with:
- [Laravel](https://laravel.com/) PHP framework
- [NuxtJs](https://nuxt.com/) Front-end SSR framework
- [Vue.js 3](https://vuejs.org/) Front-end framework
- [TailwindCSS](https://tailwindcss.com/)
- [Laravel](https://laravel.com/) PHP framework
- [NuxtJs](https://nuxt.com/) Front-end SSR framework
- [Vue.js 3](https://vuejs.org/) Front-end framework
- [TailwindCSS](https://tailwindcss.com/)
## Contribute
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).
## License
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).
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).
5 changes: 2 additions & 3 deletions client/.env.docker
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NUXT_LOG_LEVEL=
NUXT_PUBLIC_APP_URL=/
NUXT_PUBLIC_API_BASE=/api
NUXT_PRIVATE_API_BASE=http://localhost/api
NUXT_PRIVATE_API_BASE=http://ingress/api
NUXT_PUBLIC_AI_FEATURES_ENABLED=false
NUXT_PUBLIC_AMPLITUDE_CODE=
NUXT_PUBLIC_CRISP_WEBSITE_ID=
Expand All @@ -10,5 +10,4 @@ NUXT_PUBLIC_ENV=local
NUXT_PUBLIC_GOOGLE_ANALYTICS_CODE=
NUXT_PUBLIC_H_CAPTCHA_SITE_KEY=
NUXT_PUBLIC_PAID_PLANS_ENABLED=
NUXT_PUBLIC_S3_ENABLED=false
NUXT_API_SECRET=
NUXT_PUBLIC_S3_ENABLED=false
10 changes: 3 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ services:
DB_USERNAME: ${DB_USERNAME:-forge}
DB_PASSWORD: ${DB_PASSWORD:-forge}
DB_CONNECTION: ${DB_CONNECTION:-pgsql}
LOG_LEVEL: ${LOG_LEVEL:-debug}
LOG_CHANNEL: ${LOG_CHANNEL:-errorlog}
AWS_ENDPOINT: http://minio:9000
AWS_ACCESS_KEY_ID: ${MINIO_ACCESS_KEY:-minio}
AWS_SECRET_ACCESS_KEY: ${MINIO_SECRET_KEY:-minio123}
Expand All @@ -23,11 +21,13 @@ services:
env_file: ./.env
volumes:
- laravel-persist:/persist
- secrets-config:/secrets
- ./storage/logs:/usr/share/nginx/html/storage/logs

api-worker:
<<: *api
command: ./artisan queue:work
volumes:
- ./storage/logs:/usr/share/nginx/html/storage/logs

ui:
image: jhumanj/opnform-client:latest
Expand All @@ -38,11 +38,8 @@ services:
env_file:
- ./client/.env
volumes:
- secrets-config:/secrets
- ./client/.env:/app/.env



redis:
image: redis:7

Expand All @@ -65,4 +62,3 @@ services:
volumes:
laravel-persist:
postgres-data:
secrets-config:
2 changes: 0 additions & 2 deletions docker/Dockerfile.api
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ RUN chmod 777 -R storage
RUN php artisan package:discover --ansi

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

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

Expand Down
1 change: 0 additions & 1 deletion docker/Dockerfile.client
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ FROM node:20-alpine
WORKDIR /app
COPY --from=javascript-builder /app/.output/ /app/
RUN ls /app/
RUN ln -s /secrets/client.env .env
ADD ./docker/node-entrypoint /entrypoint.sh
RUN chmod a+x /entrypoint.sh

Expand Down
Loading

0 comments on commit fd9067b

Please sign in to comment.