chore: update docker & makefile

This commit is contained in:
Sonny
2023-10-24 16:55:20 +02:00
parent 1a8e4e7270
commit 8558f5e979
8 changed files with 44 additions and 47 deletions

View File

@@ -2,4 +2,12 @@ node_modules
.env
.next
.vscode
example.env
example.env
# Additional good to have ignores for dockerignore
Dockerfile*
docker-compose*
.dockerignore
*.md
.git
.gitignore

View File

@@ -4,9 +4,8 @@ WORKDIR /app
COPY ./ /app
RUN npm install
RUN npx prisma generate
RUN npm run build
EXPOSE 3000
CMD npx prisma migrate deploy && npm run start
CMD npx prisma migrate deploy && npm run start

View File

@@ -14,8 +14,5 @@ start-dev:
@echo 'Dont forget to do migrations before run dev'
start-prod:
docker-compose --env-file ../.env -f ./docker-compose.yml up -d
build:
docker build -f ./Dockerfile -t sonny/my-links ../
prod:
docker compose up -d --build

View File

@@ -4,7 +4,7 @@ services:
my-links-dev-db:
image: mysql:latest
restart: always
env_file:
- ../.env
env_file:
- .env
ports:
- 3306:3306

28
docker-compose.yml Normal file
View File

@@ -0,0 +1,28 @@
version: "3.8"
volumes:
db_volume_data:
driver: local
services:
mylinks_db:
image: mysql:latest
restart: always
volumes:
- db_volume_data:/var/lib/postgresql/data
- ./docker-config/mysql-dev-init.sql:/docker-entrypoint-initdb.d/init.sql
env_file:
- .env
mylinks:
restart: always
container_name: MyLinks
build:
context: .
ports:
- 3000:3000
env_file:
- .env
depends_on:
mylinks_db:
condition: service_started

View File

@@ -0,0 +1 @@
CREATE DATABASE mylinks;

View File

@@ -1,36 +0,0 @@
version: "3.8"
volumes:
db_volume_data:
driver: local
networks:
my_links_net:
name: my_links_net
services:
my-links-db:
image: mysql:latest
restart: always
volumes:
- db_volume_data:/var/lib/postgresql/data
env_file:
- ../.env
networks:
- my_links_net
my-links:
image: sonny/my-links:latest
container_name: MyLinks
ports:
- 3000:3000
restart: always
env_file:
- ../.env
environment:
DATABASE_URL: "mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@my-links-db:3306/${MYSQL_DATABASE}"
depends_on:
my-links-db:
condition: service_started
networks:
- my_links_net

View File

@@ -1,7 +1,7 @@
MYSQL_USER="my-user"
MYSQL_PASSWORD="my-user_passwd"
MYSQL_ROOT_PASSWORD="root_passwd"
MYSQL_DATABASE="MyLinks"
MYSQL_DATABASE="mylinks"
# Or if you need external Database
# DATABASE_IP="localhost"