Change Dockerfiles and docker-compose file #4
7 changed files with 74 additions and 29 deletions
1
backend/.dockerignore
Normal file
1
backend/.dockerignore
Normal file
|
@ -0,0 +1 @@
|
||||||
|
venv
|
|
@ -1,11 +1,19 @@
|
||||||
FROM python
|
FROM python:slim as base
|
||||||
|
|
||||||
|
FROM base as builder
|
||||||
|
|
||||||
|
RUN mkdir /install
|
||||||
|
WORKDIR /install
|
||||||
|
|
||||||
|
COPY requirements.txt /requirements.txt
|
||||||
|
|
||||||
|
RUN pip install --prefix=/install -r /requirements.txt
|
||||||
|
|
||||||
|
FROM base
|
||||||
|
|
||||||
|
COPY --from=builder /install /usr/local
|
||||||
|
|
||||||
|
COPY /src /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY requirements.txt .
|
|
||||||
|
|
||||||
RUN pip install -r requirements.txt
|
|
||||||
|
|
||||||
COPY /src .
|
|
||||||
|
|
||||||
CMD [ "flask", "run" ]
|
CMD [ "flask", "run" ]
|
||||||
|
|
|
@ -1,15 +1,19 @@
|
||||||
FROM python
|
FROM python:slim as base
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
RUN apt-get -y update && apt-get -y upgrade
|
RUN apt-get -y update && apt-get -y upgrade
|
||||||
|
|
||||||
COPY requirements.txt .
|
FROM base as builder
|
||||||
|
RUN mkdir /install
|
||||||
|
WORKDIR /install
|
||||||
|
|
||||||
RUN apt-get -y install sqlite3
|
COPY requirements.txt /requirements.txt
|
||||||
|
RUN pip install --prefix=/install -r /requirements.txt
|
||||||
|
|
||||||
RUN pip install -r requirements.txt
|
FROM base
|
||||||
|
|
||||||
COPY /src .
|
COPY --from=builder /install /usr/local
|
||||||
|
|
||||||
CMD [ "python", "app.py" ]
|
COPY /src /app
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
CMD [ "flask", "run" ]
|
||||||
|
|
21
docker-compose.prod.yml
Normal file
21
docker-compose.prod.yml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
version: '3.7'
|
||||||
|
|
||||||
|
services:
|
||||||
|
frontend-prod:
|
||||||
|
container_name: frontend-lettergen
|
||||||
|
build:
|
||||||
|
context: ./frontend
|
||||||
|
dockerfile: Dockerfile.prod
|
||||||
|
ports:
|
||||||
|
- 127.0.0.1:3000:80
|
||||||
|
backend-prod:
|
||||||
|
container_name: backend-lettergen
|
||||||
|
build:
|
||||||
|
context: ./backend
|
||||||
|
dockerfile: Dockerfile.prod
|
||||||
|
ports:
|
||||||
|
- 127.0.0.1:5000:5000
|
||||||
|
environment:
|
||||||
|
DEBUG: "no"
|
||||||
|
PORT: 5050
|
||||||
|
HOST: "0.0.0.0"
|
|
@ -1,8 +1,12 @@
|
||||||
node_modules
|
**/node_modules/
|
||||||
npm-debug.log
|
|
||||||
build
|
|
||||||
.dockerignore
|
|
||||||
**/.git
|
**/.git
|
||||||
**/.DS_Store
|
**/README.md
|
||||||
**/node_modules
|
**/LICENSE
|
||||||
.env
|
**/.vscode
|
||||||
|
**/npm-debug.log
|
||||||
|
**/coverage
|
||||||
|
**/.env
|
||||||
|
**/.editorconfig
|
||||||
|
**/.aws
|
||||||
|
**/dist
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM node:latest
|
FROM node:slim AS build
|
||||||
|
|
||||||
# set working directory
|
# set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
@ -10,7 +10,9 @@ ENV PATH /app/node_modules/.bin:$PATH
|
||||||
COPY package.json ./
|
COPY package.json ./
|
||||||
COPY package-lock.json ./
|
COPY package-lock.json ./
|
||||||
|
|
||||||
RUN npm install
|
RUN npm install && npm cache clean --force
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
# add app
|
# add app
|
||||||
COPY . ./
|
COPY . ./
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
FROM node:latest as build
|
FROM node:slim as build
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
ENV PATH /app/node_modules/.bin:$PATH
|
ENV PATH /app/node_modules/.bin:$PATH
|
||||||
|
|
||||||
COPY package.json ./
|
COPY package.json ./
|
||||||
COPY package-lock.json ./
|
COPY package-lock.json ./
|
||||||
RUN npm ci --silent
|
|
||||||
|
RUN npm ci --production && npm cache clean --force
|
||||||
COPY . ./
|
COPY . ./
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
FROM nginx:latest
|
FROM nginx:alpine
|
||||||
|
RUN apk -U upgrade
|
||||||
COPY --from=build /app/build /usr/share/nginx/html
|
COPY --from=build /app/build /usr/share/nginx/html
|
||||||
RUN rm /etc/nginx/conf.d/default.conf
|
RUN rm /etc/nginx/conf.d/default.conf
|
||||||
COPY nginx/nginx.conf /etc/nginx/conf.d
|
COPY nginx/nginx.conf /etc/nginx/conf.d
|
||||||
|
|
Loading…
Reference in a new issue