Skip to content

Commit

Permalink
deleted unneccessary .env samples as deployment is moved to 2a5-deplo…
Browse files Browse the repository at this point in the history
…y repo; migration checking; cleaned README
  • Loading branch information
Sebastian Reck committed Mar 29, 2024
1 parent 0e6cef3 commit e3933e2
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 311 deletions.
20 changes: 0 additions & 20 deletions .env.development.docker.sample

This file was deleted.

16 changes: 12 additions & 4 deletions .env.development.sample
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# being used by nextjs on `npm run dev`

DATABASE_PASSWORD="setpasswordhere"
DATABASE_PASSWORD="SET_PASSWORD_HERE"
DATABASE_USERNAME="2a5-development"
DATABASE_NAME="2a5-development"
DATABASE_PORT=5432
DATABASE_HOST="localhost"
DATABASE_URL="postgresql://${DATABASE_USERNAME}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}"
LINK_PROTOCOL="http"
LINK_HOSTNAME="localhost"
LINK_PORT=3001
LINK_PORT=3001
ADMIN_TOKEN="SET_TOKEN_HERE"
ADMIN_PORT=3002
DOCKER_API_HOSTNAME="2a5-api-development"
DOCKER_API_TARGET="runner"
DOCKER_API_IMAGE="2a5-api-development"
DOCKER_API_PORT=3000
DOCKER_API_CONTAINERNAME="2a5-api-development"
DOCKER_DB_CONTAINERNAME="2a5-db-development"
DOCKER_DB_VOLUMENAME="2a5-db-data-development"
DOCKER_DB_HOSTNAME="2a5-db-development"
16 changes: 0 additions & 16 deletions .env.prod.docker.sample

This file was deleted.

16 changes: 0 additions & 16 deletions .env.test.docker.sample

This file was deleted.

80 changes: 13 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You need to install on your local workstation:

Clone the repository:
```bash
git clone https://github.com/reckseba/2a5.git
git clone https://github.com/reckseba/2a5-api.git
```

Install your environment
Expand All @@ -46,7 +46,7 @@ npm run prismagenerate

Push the database schema to postgres (only on first start when docker volume is initially created)
```bash
npm run prismadbpush
npm run prismamigratedev
```

Run the nodejs development server:
Expand Down Expand Up @@ -85,23 +85,21 @@ npm run lint
# Deploy Development (locally)
This runs the environment on docker. It does not support hot reload.

Prepare your local config:
Prepare your local config (if not done already):
```bash
cp ./.env.development.docker.sample ./.env.development.docker.local
cp ./.env.development.sample ./.env.development.local
```
Do changes in ./.env.development.local now.

Put same db password like in `.env.development.local`
```bash
vim ./.env.development.docker.local
```

Start the web and db containers
Start the api and db containers
```bash
./deploy.sh development start
docker compose --env-file ./.env.development.local up -d
```

Push the database schema to postgres (only if not done before on first start when docker volume is initially created)
Push the database schema to postgres (only if not done before on first start when docker volume is initially created).
```bash
npm install
npm run prismamigratedeploy
```

Expand All @@ -111,59 +109,16 @@ __Warning__: This command truncates your table content!
npm run test
```

Stop the web and db containers
```bash
./deploy.sh development stop
```

Restart the web and db containers
```bash
./deploy.sh development restart
```

# Create SSH Config

Your ~/.ssh/config file should include a section such as:
```bash
Host servername
HostName 1.2.3.4
User yourusername
IdentityFile ~/.ssh/privatekeyfile
```

# Security Considerations

You could launch this API twice
- One public facing for the Client-APP with high restrictions on the database
- The other in private not being exposed to the public with a little more rights to facilitate the admin operations.

# Deploy Test
This builds, takes the increment, uploads it and runs it in docker on the server.

Prepare your local config
```bash
cp ./.env.test.docker.sample ./.env.test.docker.local
vim ./.env.test.local
```

This will build the Dockerfile until the builder stage. Then it runs a docker container named `2a5-build` from which the deployment script will copy the build increments. Finally it copies the build to your remote location, unpacks and runs it via docker compose. At last it migrates the latest database schema to the postgres instance.
Stop the api and db containers
```bash
./deploy.sh test build servername
```

The following command stops the remote containers and deletes the directory `build`.
```bash
./deploy.sh test clean servername
docker compose --env-file ./.env.development.local down
```
If you want to remove images and volumes, have a look at the Cleanup remote section.


# Cleanup locally

Delete all generated files
```bash
rm -rf .next/ node_modules/ next-env.d.ts cypress/screenshots/ cypress/videos/

```
If you want to delete your docker postgres image (volume with database entries remains)
```bash
Expand All @@ -185,15 +140,6 @@ DANGER! Erases all images
docker image prune -a
```

# Cleanup remote test
# Deployment to test/staging/production systems

Remove the volume
```bash
docker volume rm 2a5-db-data-test
```

Remove used images
```bash
docker image rm 2a5-web-test:latest
docker image rm postgres:14-alpine
```
Checkout 2a5-deploy repository.
187 changes: 0 additions & 187 deletions deploy.sh

This file was deleted.

Loading

0 comments on commit e3933e2

Please sign in to comment.