mirror of
https://github.com/spliit-app/spliit.git
synced 2026-03-07 12:56:12 +01:00
Docker container version (#39)
* + Dockerfile and compose file + Scripts dir and startup script + Build image npm script * * Moves env to file * + Tags image with info from package.json * Moves image creation to script * Updates README * Update README.md Co-authored-by: Sebastien Castiel <sebastien@castiel.me> --------- Co-authored-by: Maxime Jacob <mjacob-no-reply@proton.me> Co-authored-by: Sebastien Castiel <sebastien@castiel.me>
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -27,7 +27,7 @@ yarn-error.log*
|
|||||||
|
|
||||||
# local env files
|
# local env files
|
||||||
.env*.local
|
.env*.local
|
||||||
.env
|
*.env
|
||||||
|
|
||||||
# vercel
|
# vercel
|
||||||
.vercel
|
.vercel
|
||||||
|
|||||||
17
Dockerfile
Normal file
17
Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
FROM node:slim
|
||||||
|
|
||||||
|
EXPOSE 3000/tcp
|
||||||
|
WORKDIR /usr/app
|
||||||
|
COPY ./ ./
|
||||||
|
|
||||||
|
SHELL ["/bin/bash", "-c"]
|
||||||
|
|
||||||
|
RUN apt update && \
|
||||||
|
apt install openssl -y && \
|
||||||
|
apt clean && \
|
||||||
|
apt autoclean && \
|
||||||
|
apt autoremove && \
|
||||||
|
npm install --ignore-scripts && \
|
||||||
|
npm install -g prisma
|
||||||
|
|
||||||
|
ENTRYPOINT ["/bin/bash", "-c", "scripts/image-startup.sh"]
|
||||||
@@ -35,10 +35,16 @@ The project is open to contributions. Feel free to open an issue or even a pull-
|
|||||||
|
|
||||||
1. Clone the repository (or fork it if you intend to contribute)
|
1. Clone the repository (or fork it if you intend to contribute)
|
||||||
2. `npm install`
|
2. `npm install`
|
||||||
3. Start a PostgreSQL server. You can run `./start-local-db.sh` if you don’t have a server already.
|
3. Start a PostgreSQL server. You can run `./scripts/start-local-db.sh` if you don’t have a server already.
|
||||||
4. Copy the file `.env.example` as `.env`
|
4. Copy the file `.env.example` as `.env`
|
||||||
5. `npm run dev`
|
5. `npm run dev`
|
||||||
|
|
||||||
|
## Run in a container
|
||||||
|
1. Run `npm run build-image` to build the docker image from the Dockerfile
|
||||||
|
2. Copy the file `container.env.example` as `container.env`
|
||||||
|
3. Run `npm run start-container` to start the postgres and the spliit2 containers
|
||||||
|
3. You can access the app by browsing to http://localhost:3000
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT, see [LICENSE](./LICENSE).
|
MIT, see [LICENSE](./LICENSE).
|
||||||
|
|||||||
24
compose.yaml
Normal file
24
compose.yaml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: spliit2:latest
|
||||||
|
ports:
|
||||||
|
- 3000:3000
|
||||||
|
env_file:
|
||||||
|
- container.env
|
||||||
|
depends_on:
|
||||||
|
db:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: postgres:latest
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
env_file:
|
||||||
|
- container.env
|
||||||
|
volumes:
|
||||||
|
- /var/lib/postgresql/data:/var/lib/postgresql/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
7
container.env.example
Normal file
7
container.env.example
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# db
|
||||||
|
POSTGRES_PASSWORD=1234
|
||||||
|
|
||||||
|
# app
|
||||||
|
POSTGRES_PRISMA_URL=postgresql://postgres:${POSTGRES_PASSWORD}@db
|
||||||
|
POSTGRES_URL_NON_POOLING=postgresql://postgres:${POSTGRES_PASSWORD}@db
|
||||||
|
NEXT_PUBLIC_BASE_URL=http://localhost:3000
|
||||||
@@ -7,7 +7,9 @@
|
|||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
"postinstall": "prisma migrate deploy && prisma generate"
|
"postinstall": "prisma migrate deploy && prisma generate",
|
||||||
|
"build-image": "./scripts/build-image.sh",
|
||||||
|
"start-container": "docker compose --env-file container.env up"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hookform/resolvers": "^3.3.2",
|
"@hookform/resolvers": "^3.3.2",
|
||||||
|
|||||||
8
scripts/build-image.sh
Executable file
8
scripts/build-image.sh
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SPLIIT_APP_NAME=$(node -p -e "require('./package.json').name")
|
||||||
|
SPLIIT_VERSION=$(node -p -e "require('./package.json').version")
|
||||||
|
|
||||||
|
docker buildx build --no-cache -t ${SPLIIT_APP_NAME}:${SPLIIT_VERSION} -t ${SPLIIT_APP_NAME}:latest .
|
||||||
|
|
||||||
|
docker image prune -f
|
||||||
5
scripts/image-startup.sh
Executable file
5
scripts/image-startup.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
prisma migrate deploy
|
||||||
|
prisma generate
|
||||||
|
npm run dev
|
||||||
Reference in New Issue
Block a user