Skip to content

Commit

Permalink
Merge pull request #597 from hackforla/feat/fix-onboarding
Browse files Browse the repository at this point in the history
Feat/fix onboarding
  • Loading branch information
LoTerence authored Oct 10, 2024
2 parents b9de609 + bf6cbe2 commit 1b47cac
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 335 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ docs/
.gitignore

# Builds
backend/vite_assets_dist
backend/frontend/static/vite_assets_dist

# vite
frontend/vite.config.*.timestamp-*
34 changes: 0 additions & 34 deletions backend/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion dev/django.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ COPY . .
EXPOSE 8000

# Command to run the Django server
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
CMD ["poetry", "run", "python", "manage.py", "runserver", "0.0.0.0:8000"]
13 changes: 0 additions & 13 deletions dev/webpack.dockerfile

This file was deleted.

58 changes: 0 additions & 58 deletions docker-compose.dev.yml

This file was deleted.

87 changes: 58 additions & 29 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,58 @@
version: "3.9" # Use the version of Docker Compose that you need

services:
db:
image: postgres:16 # Use the latest PostgreSQL image
volumes:
- ./data/db:/var/lib/postgresql/data
environment:
- POSTGRES_USER=yourusername # Set the username for the PostgreSQL database
- POSTGRES_PASSWORD=yourpassword # Set the password for the PostgreSQL database
- POSTGRES_DB=yourdatabase # Set the name of the database
ports:
- "5432:5432" # Map the PostgreSQL port to the host
healthcheck:
test: ["CMD-SHELL", "pg_isready -U yourusername -d yourdatabase"]
interval: 10s
timeout: 5s
retries: 5
backend:
build: ./backend
command: python manage.py runserver 0.0.0.0:8000
restart: on-failure:10
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
db:
condition: service_healthy
name: civic-tech-jobs

services:
pgdb:
image: postgres:16
container_name: pgdb
volumes:
- postgres_data:/lib/postgresql/data
env_file:
- dev/dev.env
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5

django:
build:
context: backend
dockerfile: ../dev/django.dockerfile
container_name: django
command: >
sh -c "python manage.py makemigrations &&
python manage.py migrate &&
python manage.py runserver 0.0.0.0:8000 &&
python manage.py generateschema --file openapi-schema.yml"
ports:
- "8000:8000"
env_file:
- dev/dev.env
depends_on:
pgdb:
condition: service_healthy
develop:
watch:
- action: sync
path: ./backend
target: /usr/src/app

vite:
build:
context: frontend
dockerfile: ../dev/vite.Dockerfile
container_name: vite
env_file:
- dev/dev.env
ports:
- "5175:5175"
develop:
watch:
- action: sync
path: ./frontend
target: /usr/src/app

volumes:
postgres_data: {}
2 changes: 0 additions & 2 deletions frontend/.dockerignore

This file was deleted.

29 changes: 0 additions & 29 deletions frontend/Dockerfile

This file was deleted.

29 changes: 22 additions & 7 deletions mkdocs/docs/developer/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,22 @@ The macOS version of git involves downloading extra programs, such as Homebrew.
2. [Clone our repository to a local version on your PC.](https://docs.github.com/en/get-started/quickstart/fork-a-repo#cloning-your-forked-repository)
3. [Configuring Git to sync your fork with the original repository.](https://docs.github.com/en/get-started/quickstart/fork-a-repo#configuring-git-to-sync-your-fork-with-the-original-repository) When configuring, make sure to not blindly copy and paste the commands without making appropriate edits, especially when it involves your username or the repository name.

While developing, make sure to create new branches off of the `develop` branch. To checkout the `develop` branch into your local repository, you can do the following:

1. Navigate to the root of our directory, `CivicTechJobs/`, in the terminal.
2. Run `git remote add upstream https://github.com/hackforla/CivicTechJobs.git` - this command adds the original hackforla CivicTechJobs github repo as a remote to your local repository and names it "upstream".
3. Run `git fetch upstream develop` - this command fetches the `develop` branch.
4. Run `git checkout -b develop upstream/develop` - this command creates and checks out a new branch called "develop" that tracks the upstream `develop` branch.


## Running Docker

1. Navigate to the root of our directory, `CivicTechJobs/`, in the terminal.
2. In `dev/`, create a file named, `dev.env`.
3. In this newly created file, copy and paste the contents of `dev.env.example`. Afterwards, you must edit the lines specified below.
4. Copy the existing `CivicTechJobs/dev/linter.env.example` and create a new file called `CivicTechJobs/dev/linter.env`
5. In the terminal enter `docker compose build` and wait for the build to finish.
6. Move to the frontend directory `cd frontend` and then `npm install`
7. Then, enter `docker compose up` to run the local server.
8. Visit http://localhost:8000/ and you should see the front page of our website!
4. Move to the frontend directory `cd frontend` and then `npm install`. When this is finished, move back to the root directory `cd ..`
5. Finally, enter `docker compose up --watch` to run the local server.
6. Visit `http://localhost:8000` and you should see the front page of our website!

<details>
<summary>dev.env lines to edit</summary>
Expand All @@ -43,8 +49,16 @@ The macOS version of git involves downloading extra programs, such as Homebrew.
<li>SQL_USER: same as POSTGRES_USER</li>
<li>SQL_PASSWORD: same as POSTGRES_PASSWORD</li>
</ul>
</details>

<details>
<summary>Note on docker `--watch` flag</summary>
<p>The `--watch` flag enables hot module reloads during development. This flag requires a later version of Docker Compose(<a href="https://docs.docker.com/compose/how-tos/file-watch/" target="_blank">2.22.0</a>).</p>
<p>If you are running into issues or getting errors running `docker compose up --watch`, please make sure you have installed the latest version of Docker and Docker Desktop on your machine.</p>
</details><br>

<!-- TODO: Fix the linter container -->
<!--
### Linting
Executing `docker compose build linter` following the instructions above also creates a docker image called `linter` that can be used to run various linters/formatters against the source code. The [pre-commit](https://pre-commit.com/) is used to manage the linters/formatters, and the configurations for it can be found at: `CivicTechJobs/.pre-commit-config.yaml`
Expand All @@ -55,10 +69,11 @@ To run the linters/formatters:
2. Fill out all the lines following the instructions in the example doc and save the `linter.env` file
3. Run the linter/formatters using the following command:
- `docker compose run linter` --> runs the linters/formatters against the files staged for commit via `git add <file>`
- `docker compose run linter run --all-files` --> runs the linters/formatters across all non-excluded files in this repository
- `docker compose run linter` - runs the linters/formatters against the files staged for commit via `git add <file>`
- `docker compose run linter run --all-files` - runs the linters/formatters across all non-excluded files in this repository
_Note_: The linter does not yet incorporate with [hadolint](https://github.com/hadolint/hadolint), a Dockerfile linter. To run hadolint locally, easiest way is via: `docker run --rm --interactive docker.io/hadolint/hadolint < Dockerfile`
-->

## Frequently Asked Questions

Expand Down
Loading

0 comments on commit 1b47cac

Please sign in to comment.