Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

개발자

laravel + mysql + nginx 본문

docker

laravel + mysql + nginx

오늘만살자 2021. 3. 9. 15:58

composer create-project  laravel/laravel backend

docker-file.zip
0.00MB

cd backend

 

첨부파일 같은 폴더에 압축해제 한다.

 

Dockerfile

version: '3'
services:

  #PHP Service
  app:
    # build:
    #   context: .
    #   dockerfile: Dockerfile
    image: rayis7/laravel:latest
    #container_name: app
    restart: unless-stopped
    tty: true
    environment:
      SERVICE_NAME: app
      SERVICE_TAGS: dev
    working_dir: /var/www
    volumes:
      - ./:/var/www
      - ./php/local.ini:/usr/local/etc/php/conf.d/local.ini


  #Nginx Service
  webserver:
    image: nginx:alpine
    #container_name: webserver
    restart: unless-stopped
    tty: true
    ports:
      - "8080:80"
      - "443:443"
    volumes:
      - ./:/var/www
      - ./nginx/conf.d/:/etc/nginx/conf.d/
   

  #MySQL Service
  db:
    image: mysql:5.7.22
    #container_name: db
    restart: unless-stopped
    tty: true
    ports:
      - "3306:3306"
    environment:
      MYSQL_DATABASE: pp_count
      MYSQL_ROOT_PASSWORD: master
      SERVICE_TAGS: dev
      SERVICE_NAME: mysql
    volumes:
      - dbdata:/var/lib/mysql/
      - ./mysql/my.cnf:/etc/mysql/my.cnf
  
  
 
      
      
#Volumes
volumes:
  dbdata:
    driver: local

docker build -t rayis7/laravel .

 

 

docker-compose.yml

 

FROM php:7.3-fpm

# Copy composer.lock and composer.json
COPY composer.lock composer.json /var/www/

# Set working directory
WORKDIR /var/www

# Install dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    libpng-dev \
    libjpeg62-turbo-dev \
    libfreetype6-dev \
    locales \
    zip \
    libzip-dev \
    jpegoptim optipng pngquant gifsicle \
    vim \
    unzip \
    git \
    curl

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Install extensions
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl
RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
RUN docker-php-ext-install gd

# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www

# Copy existing application directory contents
COPY . /var/www

# Copy existing application directory permissions
COPY --chown=www:www . /var/www

# Change current user to www
USER www

# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]

#docker build -t rayis7/laravel .

docker swarm init  

 

docker stack deploy -c docker-comose.yml rayis

 

 

'docker' 카테고리의 다른 글

docker 일반계정사용하기  (0) 2021.03.09
docker install  (0) 2021.03.09
docker remove  (0) 2021.03.09
portainer install  (0) 2021.03.09