mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 07:03:25 +00:00
chore: setup docker env
This commit is contained in:
20
.dockerignore
Normal file
20
.dockerignore
Normal file
@@ -0,0 +1,20 @@
|
||||
# Adonis default .gitignore ignores
|
||||
node_modules
|
||||
build
|
||||
coverage
|
||||
.vscode
|
||||
.DS_STORE
|
||||
# .env
|
||||
tmp
|
||||
storage
|
||||
|
||||
# Additional .gitignore ignores (any custom file you wish)
|
||||
.idea
|
||||
|
||||
# Additional good to have ignores for dockerignore
|
||||
Dockerfile*
|
||||
docker-compose*
|
||||
.dockerignore
|
||||
*.md
|
||||
.git
|
||||
.gitignore
|
||||
@@ -8,5 +8,7 @@ SESSION_DRIVER=cookie
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=5432
|
||||
DB_USER=postgres
|
||||
DB_PASSWORD=
|
||||
DB_DATABASE=
|
||||
DB_PASSWORD=my-links-pwd
|
||||
DB_DATABASE=my-links
|
||||
GOOGLE_CLIENT_ID=
|
||||
GOOGLE_CLIENT_SECRET=
|
||||
|
||||
33
Dockerfile
Normal file
33
Dockerfile
Normal file
@@ -0,0 +1,33 @@
|
||||
# Source: https://docs.adonisjs.com/cookbooks/dockerizing-adonis#document
|
||||
|
||||
FROM node:lts-alpine3.19
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Install dependencies
|
||||
COPY package*.json ./
|
||||
RUN npm ci --omit="dev"
|
||||
|
||||
# Copy app source code
|
||||
COPY . .
|
||||
|
||||
# Build app
|
||||
RUN npm install
|
||||
RUN npm run build --omit="dev"
|
||||
|
||||
COPY ./.env ./build
|
||||
|
||||
ENV PORT=$PORT
|
||||
ENV HOST=0.0.0.0
|
||||
ENV APP_KEY=DIhtF2IY1-MCAm_wlh3VYx7KLVOhpeOb
|
||||
ENV NODE_ENV=production
|
||||
ENV LOG_LEVEL=debug
|
||||
ENV CACHE_VIEWS=false
|
||||
ENV SESSION_DRIVER=cookie
|
||||
|
||||
# Expose port
|
||||
EXPOSE $PORT
|
||||
|
||||
# Start app
|
||||
CMD node build/bin/console.js migration:run --force && node build/bin/server.js
|
||||
9
Makefile
Normal file
9
Makefile
Normal file
@@ -0,0 +1,9 @@
|
||||
dev:
|
||||
docker compose down
|
||||
docker compose -f dev.docker-compose.yml up -d --wait
|
||||
node ace migration:fresh
|
||||
npm run dev
|
||||
|
||||
prod:
|
||||
docker compose -f dev.docker-compose.yml down
|
||||
docker compose up -d --build --wait
|
||||
34
dev.docker-compose.yml
Normal file
34
dev.docker-compose.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
name: dev-stack
|
||||
services:
|
||||
postgres:
|
||||
container_name: postgres
|
||||
image: postgres:16
|
||||
restart: always
|
||||
environment:
|
||||
- POSTGRES_DB=${DB_DATABASE}
|
||||
- POSTGRES_USER=${DB_USER}
|
||||
- POSTGRES_PASSWORD=${DB_PASSWORD}
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'pg_isready']
|
||||
volumes:
|
||||
- postgres_volume:/var/lib/postgresql/data
|
||||
ports:
|
||||
- '${DB_PORT}:5432'
|
||||
|
||||
pgadmin:
|
||||
container_name: pgadmin
|
||||
image: dpage/pgadmin4:8.5
|
||||
restart: always
|
||||
environment:
|
||||
- PGADMIN_DEFAULT_EMAIL=myemail@gmail.com
|
||||
- PGADMIN_DEFAULT_PASSWORD=a12345678
|
||||
depends_on:
|
||||
- postgres
|
||||
volumes:
|
||||
- ./docker-config/servers_pgadmin.json:/pgadmin4/servers.json
|
||||
ports:
|
||||
- '5050:80'
|
||||
|
||||
volumes:
|
||||
postgres_volume:
|
||||
name: postgres_test_adonisv6
|
||||
34
docker-compose.yml
Normal file
34
docker-compose.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
name: my-links
|
||||
services:
|
||||
postgres:
|
||||
container_name: postgres
|
||||
image: postgres:16
|
||||
restart: always
|
||||
environment:
|
||||
- POSTGRES_DB=${DB_DATABASE}
|
||||
- POSTGRES_USER=${DB_USER}
|
||||
- POSTGRES_PASSWORD=${DB_PASSWORD}
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'pg_isready']
|
||||
volumes:
|
||||
- postgres-volume:/var/lib/postgresql/data
|
||||
|
||||
my-links:
|
||||
container_name: my-links
|
||||
restart: always
|
||||
build:
|
||||
context: .
|
||||
environment:
|
||||
- DB_HOST=postgres
|
||||
- HOST=0.0.0.0
|
||||
env_file:
|
||||
- .env
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- ${PORT}:3333
|
||||
|
||||
volumes:
|
||||
postgres-volume:
|
||||
name: postgres-prod-my-links
|
||||
13
docker-config/servers_pgadmin.json
Normal file
13
docker-config/servers_pgadmin.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"Servers": {
|
||||
"1": {
|
||||
"Name": "project",
|
||||
"Group": "Server Group 1",
|
||||
"Port": 5432,
|
||||
"Username": "postgres",
|
||||
"Host": "postgres",
|
||||
"SSLMode": "prefer",
|
||||
"MaintenanceDB": "my-links"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user