настройка и правка docker сборки

main
Пилипенко Андрей Борисович 1 month ago
parent a7eae2bb63
commit 473250194c

@ -1,9 +0,0 @@
services:
web:
build:
context: backend
target: dev-envs
ports:
- '8090:8090'
volumes:
- /var/run/docker.sock:/var/run/docker.sock

@ -1,24 +1,27 @@
# syntax=docker/dockerfile:1.4
FROM --platform=linux/arm64/v8 python:3.12 AS builder
EXPOSE 8080
WORKDIR /app
COPY requirements.txt /app
FROM python:3.12 AS builder
WORKDIR /backend
COPY requirements.txt .
RUN pip3 install -r requirements.txt --no-cache-dir
COPY . /app
ENTRYPOINT ["python3"]
CMD ["manage.py", "runserver", "0.0.0.0:8080"]
FROM builder as dev-envs
RUN <<EOF
apk update
apk add git
EOF
RUN <<EOF
addgroup -S docker
adduser -S --shell /bin/bash --ingroup docker vscode
EOF
# install Docker tools (cli, buildx, compose)
COPY --from=gloursdocker/docker / /
CMD ["manage.py", "runserver", "0.0.0.0:8080"]
COPY . .
EXPOSE 8091
CMD ["sh", "-c", "python manage.py runserver 0.0.0.0:8091"]
FROM builder AS development
RUN apt-get update && apt-get install -y \
git \
&& rm -rf /var/lib/apt/lists/*
RUN useradd -m -s /bin/bash developer
USER developer
CMD ["sh", "-c", "python manage.py runserver 0.0.0.0:8091"]

@ -1,45 +1,34 @@
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fexamples%2Ftree%2Fmain%2Fpython%2Fdjango&demo-title=Django%20%2B%20Vercel&demo-description=Use%20Django%204%20on%20Vercel%20with%20Serverless%20Functions%20using%20the%20Python%20Runtime.&demo-url=https%3A%2F%2Fdjango-template.vercel.app%2F&demo-image=https://assets.vercel.com/image/upload/v1669994241/random/django.png)
# Django and Vercel
This example shows how to use Django 4 on Vercel with Serverless Functions using the [Python Runtime](https://vercel.com/docs/concepts/functions/serverless-functions/runtimes/python).
Version 1.0.0
## Demo5
https://django-template.vercel.app/
## How it Works
Our Django application, `example` is configured as an installed application in `vercel_app/settings.py`:
Our Django application, `example` is configured as an installed application settings.py`:
```python
# vercel_app/settings.py
# settings.py
INSTALLED_APPS = [
# ...
'django_app',
]
```
We allow "\*.vercel.app" subdomains in `ALLOWED_HOSTS`, in addition to 127.0.0.1:
We allow subdomains in `ALLOWED_HOSTS`, in addition to 127.0.0.1:
```python
# vercel_app/settings.py
ALLOWED_HOSTS = ['127.0.0.1', '.vercel.app']
# settings.py
ALLOWED_HOSTS = ['127.0.0.1']
```
The `wsgi` module must use a public variable named `app` to expose the WSGI application:
```python
# vercel_app/wsgi.py
# wsgi.py
app = get_wsgi_application()
```
The corresponding `WSGI_APPLICATION` setting is configured to use the `app` variable from the `vercel_app.wsgi` module:
The corresponding `WSGI_APPLICATION` setting is configured to use the `beckend'` variable from the module:
```python
# vercel_app/settings.py
WSGI_APPLICATION = 'vercel_app.wsgi.app'
WSGI_APPLICATION = 'vercel_app.wsgi.beckend'
```
There is a single view which renders the current time in `example/views.py`:
@ -47,10 +36,8 @@ There is a single view which renders the current time in `example/views.py`:
```python
# django_app/views.py
from datetime import datetime
from django.http import HttpResponse
def index(request):
now = datetime.now()
html = f'''
@ -69,7 +56,6 @@ This view is exposed a URL through `example/urls.py`:
```python
# django_app/urls.py
from django.urls import path
from django_app.views import index
urlpatterns = [
@ -77,7 +63,7 @@ urlpatterns = [
]
```
Finally, it's made accessible to the Django server inside `vercel_app/urls.py`:
Finally, it's made accessible to the Django server inside `urls.py`:
```python
# vercel_app/urls.py
@ -96,28 +82,17 @@ This example uses the Web Server Gateway Interface (WSGI) with Django to enable
```bash
python manage.py collectstatic
python manage.py runserver 8080
python manage.py runserver 8090
docker rmi -f <image_id>
docker compose down && docker compose build --no-cache && docker compose up
Docker: https://sematext.com/blog/docker-logs-location/
UI: https://docs.sencha.com/touch/2.3.1/#!/api
Localhost: https://letsencrypt.org/ru/docs/certificates-for-localhost/
ssh first@192.168.1.100
less +G /var/lib/docker/containers/<container_id>/<container_id>-json.log
```
https://c0.klipartz.com/pngpicture/54/511/gratis-png-meme-informacion-pegatina-telegrama-meme-thumbnail.png
Your Django application is now available at `http://localhost:8000`.
## One-Click Deploy
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=vercel-examples):
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fexamples%2Ftree%2Fmain%2Fpython%2Fdjango&demo-title=Django%20%2B%20Vercel&demo-description=Use%20Django%204%20on%20Vercel%20with%20Serverless%20Functions%20using%20the%20Python%20Runtime.&demo-url=https%3A%2F%2Fdjango-template.vercel.app%2F&demo-image=https://assets.vercel.com/image/upload/v1669994241/random/django.png)
Your Django application is now available at `http://localhost:8090`.

@ -1,10 +1,36 @@
version: '3.8'
services:
web:
frontend:
platform: linux/arm64/v8
build:
context: frontend
target: development
container_name: firstsoftwarrior-shop-frontend
ports:
- "8090:8090"
environment:
- NODE_ENV=development
volumes:
- ./frontend:/frontend
- /frontend/node_modules
depends_on:
- backend
backend:
platform: linux/arm64/v8
image: firstsoftwarrior/game_shop
build:
context: backend
target: builder
container_name: firstsoftwarrior-game_shop
container_name: firstsoftwarrior-shop-backend
ports:
- '8090:8090'
- '8091:8091'
environment:
- DEBUG=True
- ALLOWED_HOSTS=localhost,127.0.0.1,192.168.1.100,backend,shop.softwarrior.ru
volumes:
- ./backend:/backend
networks:
default:
name: game-shop-net

@ -0,0 +1,17 @@
server {
listen 8090;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri /index.html =404;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

@ -0,0 +1,37 @@
# syntax=docker/dockerfile:1.4
FROM node:lts AS development
WORKDIR /frontend
COPY package*.json ./
RUN npm ci
COPY . .
EXPOSE 8090
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0", "--port", "8090"]
FROM node:lts AS build
WORKDIR /frontend
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM nginx:alpine AS production
COPY --from=build /frontend/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 8090
CMD ["nginx", "-g", "daemon off;"]

@ -74,7 +74,6 @@
"integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/code-frame": "^7.27.1",
"@babel/generator": "^7.28.5",
@ -390,7 +389,6 @@
"resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.14.0.tgz",
"integrity": "sha512-O000MLDBDdk/EohJPFUqvnp4qnHeYkVP5B0xEG0D/L7cOKP9kefu2DXn8dj74cQfsEzUqh+sr1RzFqiL1o+PpA==",
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/runtime": "^7.18.3",
"@emotion/babel-plugin": "^11.13.5",
@ -434,7 +432,6 @@
"resolved": "https://registry.npmjs.org/@emotion/styled/-/styled-11.14.1.tgz",
"integrity": "sha512-qEEJt42DuToa3gurlH4Qqc1kVpNq8wO8cJtDzU46TjlzWjDlsVyevtYCRijVq3SrHsROS+gVQ8Fnea108GnKzw==",
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/runtime": "^7.18.3",
"@emotion/babel-plugin": "^11.13.5",
@ -1265,7 +1262,6 @@
"resolved": "https://registry.npmjs.org/@mui/material/-/material-7.3.4.tgz",
"integrity": "sha512-gEQL9pbJZZHT7lYJBKQCS723v1MGys2IFc94COXbUIyCTWa+qC77a7hUax4Yjd5ggEm35dk4AyYABpKKWC4MLw==",
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/runtime": "^7.28.4",
"@mui/core-downloads-tracker": "^7.3.4",
@ -1924,7 +1920,6 @@
"integrity": "sha512-uWN8YqxXxqFMX2RqGOrumsKeti4LlmIMIyV0lgut4jx7KQBcBiW6vkDtIBvHnHIquwNfJhk8v2OtmO8zXWHfPA==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"undici-types": "~7.16.0"
}
@ -1946,7 +1941,6 @@
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.2.tgz",
"integrity": "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA==",
"license": "MIT",
"peer": true,
"dependencies": {
"csstype": "^3.0.2"
}
@ -2022,7 +2016,6 @@
"integrity": "sha512-BnOroVl1SgrPLywqxyqdJ4l3S2MsKVLDVxZvjI1Eoe8ev2r3kGDo+PcMihNmDE+6/KjkTubSJnmqGZZjQSBq/g==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@typescript-eslint/scope-manager": "8.46.2",
"@typescript-eslint/types": "8.46.2",
@ -2275,7 +2268,6 @@
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
"dev": true,
"license": "MIT",
"peer": true,
"bin": {
"acorn": "bin/acorn"
},
@ -2438,7 +2430,6 @@
}
],
"license": "MIT",
"peer": true,
"dependencies": {
"baseline-browser-mapping": "^2.8.19",
"caniuse-lite": "^1.0.30001751",
@ -2788,7 +2779,6 @@
"integrity": "sha512-t5aPOpmtJcZcz5UJyY2GbvpDlsK5E8JqRqoKtfiKE3cNh437KIqfJr3A3AKf5k64NPx6d0G3dno6XDY05PqPtw==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.8.0",
"@eslint-community/regexpp": "^4.12.1",
@ -3967,7 +3957,6 @@
"resolved": "https://registry.npmjs.org/react/-/react-19.2.0.tgz",
"integrity": "sha512-tmbWg6W31tQLeB5cdIBOicJDJRR2KzXsV7uSK9iNfLWQ5bIZfxuPEHp7M8wiHyHnn0DD1i7w3Zmin0FtkrwoCQ==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=0.10.0"
}
@ -3977,7 +3966,6 @@
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.0.tgz",
"integrity": "sha512-UlbRu4cAiGaIewkPyiRGJk0imDN2T3JjieT6spoL2UeSf5od4n5LB/mQ4ejmxhCFT1tYe8IvaFulzynWovsEFQ==",
"license": "MIT",
"peer": true,
"dependencies": {
"scheduler": "^0.27.0"
},
@ -3990,7 +3978,6 @@
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.66.0.tgz",
"integrity": "sha512-xXBqsWGKrY46ZqaHDo+ZUYiMUgi8suYu5kdrS20EG8KiL7VRQitEbNjm+UcrDYrNi1YLyfpmAeGjCZYXLT9YBw==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=18.0.0"
},
@ -4013,7 +4000,6 @@
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.2.0.tgz",
"integrity": "sha512-ROY9fvHhwOD9ySfrF0wmvu//bKCQ6AeZZq1nJNtbDC+kk5DuSuNX/n6YWYF/SYy7bSba4D4FSz8DJeKY/S/r+g==",
"license": "MIT",
"peer": true,
"dependencies": {
"@types/use-sync-external-store": "^0.0.6",
"use-sync-external-store": "^1.4.0"
@ -4113,8 +4099,7 @@
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz",
"integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==",
"license": "MIT",
"peer": true
"license": "MIT"
},
"node_modules/redux-thunk": {
"version": "3.1.0",
@ -4502,7 +4487,6 @@
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=12"
},
@ -4573,7 +4557,6 @@
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"dev": true,
"license": "Apache-2.0",
"peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
@ -4669,7 +4652,6 @@
"integrity": "sha512-ZWyE8YXEXqJrrSLvYgrRP7p62OziLW7xI5HYGWFzOvupfAlrLvURSzv/FyGyy0eidogEM3ujU+kUG1zuHgb6Ug==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"esbuild": "^0.25.0",
"fdir": "^6.5.0",
@ -4763,7 +4745,6 @@
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=12"
},

@ -12,7 +12,7 @@ import {
import { type SyntheticEvent, useCallback } from 'react'
import { Link } from 'react-router-dom'
import { CartButton } from './cart-button'
import { useAppDispatch, useAppSelector, shop } from '../storage'
import { useAppSelector, shop } from '../storage'
export type ProductCardProps = {
productId: number
@ -31,11 +31,15 @@ export const ProductCard = ({ productId }: ProductCardProps) => {
cost: '',
}
const dispatch = useAppDispatch()
console.debug({reserved, type})
//const dispatch = useAppDispatch()
const quantity = 5
const handleCart = useCallback((num: number) => {}, [])
const handleCart = useCallback((num: number) => {
console.debug({num})
}, [])
return (
<Grid size={{ xs: 12, sm: 6, md: 4, lg: 4 }}>

@ -29,9 +29,13 @@ export const ProductDetail = ({ productId }: ProductDetailProps) => {
cost: '',
}
console.debug({id, reserved, type})
const quantity = 5
const handleCart = useCallback((num: number) => {}, [])
const handleCart = useCallback((num: number) => {
console.debug({num})
}, [])
return (
<Grid container direction="column" justifyContent="center" alignItems="center">

@ -13,7 +13,6 @@ import PagesIcon from '@mui/icons-material/Pages'
import { type JSX, type MouseEvent, useState } from 'react'
import { Link, useNavigate } from 'react-router-dom'
import { Badge } from '@mui/material'
import { useAppDispatch } from '../storage'
const EXIT_NAME = 'Выйти'
const CART_NAME = 'Корзина'
@ -51,7 +50,6 @@ export const Header = (): JSX.Element => {
setAnchorElNav(null)
}
const dispatch = useAppDispatch()
const navigate = useNavigate()
const handleCloseUserMenu =

@ -6,7 +6,6 @@ import { yupResolver } from '@hookform/resolvers/yup'
import { toast } from 'react-toastify'
import { Link as RouterLink, useLocation, useNavigate } from 'react-router-dom'
import * as yup from 'yup'
import { useAppDispatch } from '../storage'
import type { ErrorType } from '../types'
export interface RegistrFormValues {
@ -22,8 +21,6 @@ export const registrFormSchema = yup.object({
})
export const RegisterPage = (): JSX.Element => {
const dispatch = useAppDispatch()
const { state } = useLocation()
const navigate = useNavigate()
@ -47,6 +44,7 @@ export const RegisterPage = (): JSX.Element => {
const submitHandler: SubmitHandler<RegistrFormValues> = async values => {
try {
console.debug({values})
// TODO: логинемся и запрашиваем все данные
toast.success('Вы успешно вошли в систему!')
// переходит туда откуда выпали на логин

@ -1,4 +1,4 @@
import { createTheme, useTheme } from '@mui/material'
import { createTheme } from '@mui/material'
// import { lime, purple } from '@mui/material/colors'
export const theme = createTheme({})

Loading…
Cancel
Save