Separacion de docker para producion y desarrollo
This commit is contained in:
23
backend/Dockerfile.prod
Normal file
23
backend/Dockerfile.prod
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
FROM alpine:3
|
||||||
|
|
||||||
|
RUN apk update
|
||||||
|
RUN apk --no-cache add php8 php8-openssl php8-pdo php8-pdo_mysql \
|
||||||
|
php8-pdo_sqlite php8-pdo_pgsql php8-mbstring \
|
||||||
|
php8-phar php8-curl php8-dom php8-xml \
|
||||||
|
php8-xmlwriter php8-tokenizer \
|
||||||
|
zip unzip curl sqlite
|
||||||
|
|
||||||
|
RUN ln -s /usr/bin/php8 /usr/bin/php
|
||||||
|
RUN curl -s https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer
|
||||||
|
|
||||||
|
WORKDIR /lumen
|
||||||
|
|
||||||
|
COPY composer.json .
|
||||||
|
COPY composer.lock .
|
||||||
|
|
||||||
|
RUN composer install --no-ansi --no-dev --no-interaction --no-plugins \
|
||||||
|
--no-progress --no-scripts --optimize-autoloader
|
||||||
|
|
||||||
|
COPY . /lumen
|
||||||
|
|
||||||
|
ENTRYPOINT ["php", "-S", "0.0.0.0:8080", "-t", "public"]
|
||||||
39
docker-compose.prod.yml
Normal file
39
docker-compose.prod.yml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
version: "3.9"
|
||||||
|
|
||||||
|
services:
|
||||||
|
backend:
|
||||||
|
build:
|
||||||
|
context: ./backend
|
||||||
|
dockerfile: ./Dockerfile.prod
|
||||||
|
ports:
|
||||||
|
- 8080:8080
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
build:
|
||||||
|
context: ./frontend
|
||||||
|
dockerfile: ./Dockerfile.prod
|
||||||
|
ports:
|
||||||
|
- 4200:80
|
||||||
|
|
||||||
|
database:
|
||||||
|
image: postgres:13
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
POSTGRES_PASSWORD: admin
|
||||||
|
PGDATA: "/var/lib/postgresql/data/pgdata"
|
||||||
|
volumes:
|
||||||
|
- ./database/init:/docker-entrypoint-initdb.d
|
||||||
|
- database:/var/lib/postgresql/data
|
||||||
|
ports:
|
||||||
|
- 5400:5432
|
||||||
|
|
||||||
|
cache:
|
||||||
|
image: redis
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- cache:/data
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
database:
|
||||||
|
cache:
|
||||||
|
|
||||||
@@ -24,8 +24,16 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./frontend
|
context: ./frontend
|
||||||
dockerfile: ./Dockerfile
|
dockerfile: ./Dockerfile
|
||||||
|
volumes:
|
||||||
|
- ./frontend/src:/angular/src
|
||||||
|
- ./frontend/angular.json:/angular/angular.json
|
||||||
|
- ./frontend/karma.conf.js:/angular/karma.conf.js
|
||||||
|
- ./frontend/README.md:/angular/README.md
|
||||||
|
- ./frontend/tsconfig.app.json:/angular/tsconfig.app.json
|
||||||
|
- ./frontend/tsconfig.json:/angular/tsconfig.json
|
||||||
|
- ./frontend/tsconfig.spec.json:/angular/tsconfig.spec.json
|
||||||
ports:
|
ports:
|
||||||
- 4200:80
|
- 4200:4200
|
||||||
|
|
||||||
database:
|
database:
|
||||||
image: postgres:13
|
image: postgres:13
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
FROM node:alpine as build
|
FROM node:alpine as build
|
||||||
|
|
||||||
WORKDIR /angular
|
WORKDIR /angular
|
||||||
COPY package.json package-lock.json /angular/
|
COPY package.json package-lock.json /angular/
|
||||||
RUN npm install
|
RUN npm install
|
||||||
COPY . /angular
|
COPY . /angular
|
||||||
RUN npm run build --prod
|
|
||||||
|
|
||||||
FROM nginx:stable-alpine
|
ENTRYPOINT ["npm", "run", "start"]
|
||||||
COPY --from=build /angular/dist/frontend /usr/share/nginx/html
|
|
||||||
|
|||||||
10
frontend/Dockerfile.prod
Normal file
10
frontend/Dockerfile.prod
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
FROM node:alpine as build
|
||||||
|
WORKDIR /angular
|
||||||
|
COPY package.json package-lock.json /angular/
|
||||||
|
RUN npm install
|
||||||
|
COPY . /angular
|
||||||
|
RUN npm run build --prod
|
||||||
|
|
||||||
|
FROM nginx:stable-alpine
|
||||||
|
COPY --from=build /angular/dist/frontend /usr/share/nginx/html
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
8
frontend/nginx.conf
Normal file
8
frontend/nginx.conf
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
location / {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html index.htm;
|
||||||
|
try_files $uri $uri/ /index.html =404;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "ng serve",
|
"start": "ng serve --host 0.0.0.0",
|
||||||
"build": "ng build",
|
"build": "ng build",
|
||||||
"watch": "ng build --watch --configuration development",
|
"watch": "ng build --watch --configuration development",
|
||||||
"test": "ng test"
|
"test": "ng test"
|
||||||
|
|||||||
Reference in New Issue
Block a user