Docker setup for web application containerization

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1212
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    852
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    815

Docker Web Application Containerization Setup

Docker packages an application with all its dependencies into an isolated container. Identical behavior across dev, staging, and production. Simplifies deployment and horizontal scaling.

Multi-stage Dockerfile for PHP/Laravel

# Dockerfile
# Stage 1: Install PHP dependencies
FROM composer:2.7 AS composer
WORKDIR /app
COPY composer.json composer.lock ./
RUN composer install --no-dev --optimize-autoloader --no-scripts --no-interaction

# Stage 2: Build frontend
FROM node:20-alpine AS node
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY resources/js ./resources/js
COPY resources/css ./resources/css
COPY vite.config.ts tsconfig.json ./
RUN npm run build

# Stage 3: Final image
FROM php:8.3-fpm-alpine

RUN apk add --no-cache \
    nginx \
    supervisor \
    postgresql-libs \
    && docker-php-ext-install pdo_pgsql opcache

WORKDIR /var/www/html

# Copy from previous stages
COPY --from=composer /app/vendor ./vendor
COPY --from=node /app/public/build ./public/build
COPY . .

# OPcache configuration
RUN echo "opcache.enable=1\nopcache.memory_consumption=256\nopcache.validate_timestamps=0" \
    >> /usr/local/etc/php/conf.d/opcache.ini

# Run via supervisor (nginx + php-fpm)
COPY docker/supervisord.conf /etc/supervisord.conf
COPY docker/nginx.conf /etc/nginx/nginx.conf

RUN chown -R www-data:www-data storage bootstrap/cache

EXPOSE 80
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]

Multi-stage Dockerfile for Node.js

FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:20-alpine AS production
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/public ./public

USER node
EXPOSE 3000
CMD ["node", "dist/server.js"]

.dockerignore

node_modules
.git
.env
*.log
/tests
/coverage
/.github
docker-compose*.yml
Dockerfile*

Image size optimization

# Use alpine images
FROM php:8.3-fpm-alpine    # ~80 MB vs 400 MB for debian-based

# Combine RUN commands
RUN apk add --no-cache curl \
    && rm -rf /var/cache/apk/*

# Do not install dev dependencies
RUN composer install --no-dev --optimize-autoloader

# BuildKit for parallel build
# export DOCKER_BUILDKIT=1
# docker buildx build --cache-from type=registry,ref=myapp:cache .

Production execution

# Build image
docker build -t myapp:v1.2.3 .

# Run
docker run -d \
    --name myapp \
    --restart unless-stopped \
    -p 80:80 \
    -e APP_ENV=production \
    -e DB_HOST=db.internal \
    --env-file .env.production \
    -v /var/log/myapp:/var/www/html/storage/logs \
    myapp:v1.2.3

# Update to new version (zero-downtime)
docker pull myapp:v1.3.0
docker stop myapp && docker rm myapp
docker run -d --name myapp ... myapp:v1.3.0

Health check

HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
    CMD curl -f http://localhost/health || exit 1

GitHub Actions → Docker Registry

- name: Build and push Docker image
  uses: docker/build-push-action@v5
  with:
    context: .
    push: true
    tags: |
      registry.example.com/myapp:latest
      registry.example.com/myapp:${{ github.sha }}
    cache-from: type=registry,ref=registry.example.com/myapp:cache
    cache-to: type=registry,ref=registry.example.com/myapp:cache,mode=max

Timeline

Creating Dockerfile + registry setup + CI build: 2–3 days.