-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add build context to compose Signed-off-by: Daniel Ekman <[email protected]> * Update Docker documentation with build instructions Enhance Docker deployment documentation by: - Adding detailed instructions for building Docker images - Providing two methods for image building (Docker Compose and manual) - Clarifying how to use local images with docker-compose.override.yml * Add development Docker configuration Introduce development-specific Docker configuration: - Create docker-compose.dev.yml for local development setup - Add nginx.dev.conf with development CORS settings - Update Dockerfile.api to support environment-specific dependency installation - Configure development services with appropriate volumes and environment variables * Improve Docker and Development Documentation - Remove platform-specific ARM64 constraints in docker-compose.dev.yml - Enhance Nginx configuration with improved proxy and HMR settings - Update documentation for development setup and Docker deployment - Add new Docker development documentation page - Refactor getting started guide with clearer development instructions * Enhance Docker configuration and CI/CD pipeline - Update Docker Compose files with improved service configurations - Add database healthcheck in docker-compose.yml - Refactor GitHub Actions workflow for Docker image publishing - Optimize Dockerfile.api with multi-stage build and environment-specific configurations - Update Nginx configuration for development and production environments * Add GitHub Actions permissions for Docker image publishing Configure GitHub Actions workflow with explicit read and write permissions for content and packages to improve security and clarity of Docker image deployment process --------- Signed-off-by: Daniel Ekman <[email protected]> Co-authored-by: Daniel Ekman <[email protected]>
- Loading branch information
Showing
12 changed files
with
465 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,70 @@ | ||
name: Publish Docker image | ||
name: Publish Docker Images | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
branches: | ||
- main | ||
paths: | ||
- "api/**" | ||
- "client/**" | ||
- "docker/**" | ||
- "docker-compose*.yml" | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
jobs: | ||
push_to_registry: | ||
name: Push Docker image to Docker Hub | ||
name: Push Docker images to Docker Hub | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get tag name | ||
- name: Get version info | ||
run: | | ||
( | ||
echo "TAG_NAME=${GITHUB_REF#refs/*/v}"; | ||
echo "DOCKER_UI_REPO=${{secrets.DOCKER_UI_REPO}}" | ||
echo "DOCKER_API_REPO=${{secrets.DOCKER_API_REPO}}" | ||
) >> $GITHUB_ENV | ||
if [[ $GITHUB_REF == refs/tags/* ]]; then | ||
echo "VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV | ||
echo "API_TAGS=${{secrets.DOCKER_API_REPO}}:latest,${{secrets.DOCKER_API_REPO}}:${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV | ||
echo "UI_TAGS=${{secrets.DOCKER_UI_REPO}}:latest,${{secrets.DOCKER_UI_REPO}}:${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV | ||
else | ||
echo "VERSION=dev" >> $GITHUB_ENV | ||
echo "API_TAGS=${{secrets.DOCKER_API_REPO}}:dev" >> $GITHUB_ENV | ||
echo "UI_TAGS=${{secrets.DOCKER_UI_REPO}}:dev" >> $GITHUB_ENV | ||
fi | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Log in to Docker Hub | ||
run: docker login -u "${{ secrets.DOCKER_USERNAME }}" -p "${{ secrets.DOCKER_ACCESS_TOKEN }}" | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Build docker api image | ||
run: docker build -f docker/Dockerfile.api . -t $DOCKER_API_REPO:latest -t $DOCKER_API_REPO:$TAG_NAME | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build docker ui image | ||
run: docker build -f docker/Dockerfile.client . -t $DOCKER_UI_REPO:latest -t $DOCKER_UI_REPO:$TAG_NAME | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_ACCESS_TOKEN }} | ||
|
||
- name: Push Docker api image | ||
run: docker push $DOCKER_API_REPO:latest && docker push $DOCKER_API_REPO:$TAG_NAME | ||
- name: Build and push API image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: docker/Dockerfile.api | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
build-args: | | ||
APP_ENV=${{ env.VERSION == 'dev' && 'local' || 'production' }} | ||
tags: ${{ env.API_TAGS }} | ||
|
||
- name: Push Docker ui image | ||
run: docker push $DOCKER_UI_REPO:latest && docker push $DOCKER_UI_REPO:$TAG_NAME | ||
- name: Build and push Client image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: docker/Dockerfile.client | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ env.UI_TAGS }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
services: | ||
api: &api-base | ||
image: jhumanj/opnform-api:dev | ||
build: | ||
context: . | ||
dockerfile: docker/Dockerfile.api | ||
args: | ||
APP_ENV: local | ||
volumes: | ||
- ./api:/usr/share/nginx/html:delegated | ||
- /usr/share/nginx/html/vendor # Exclude vendor directory from the mount | ||
- ./api/storage:/usr/share/nginx/html/storage:delegated # Mount storage directory directly | ||
environment: | ||
DB_HOST: db | ||
REDIS_HOST: redis | ||
DB_DATABASE: ${DB_DATABASE:-forge} | ||
DB_USERNAME: ${DB_USERNAME:-forge} | ||
DB_PASSWORD: ${DB_PASSWORD:-forge} | ||
DB_CONNECTION: ${DB_CONNECTION:-pgsql} | ||
FILESYSTEM_DISK: local | ||
LOCAL_FILESYSTEM_VISIBILITY: public | ||
APP_ENV: local | ||
PHP_IDE_CONFIG: "serverName=Docker" | ||
XDEBUG_MODE: "${XDEBUG_MODE:-off}" | ||
XDEBUG_CONFIG: "client_host=host.docker.internal" | ||
APP_URL: "http://localhost" | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
|
||
ui: | ||
image: jhumanj/opnform-client:dev | ||
build: | ||
context: . | ||
dockerfile: docker/Dockerfile.client | ||
command: sh -c "npm install && NITRO_HOST=0.0.0.0 NITRO_PORT=3000 npm run dev" | ||
volumes: | ||
- ./client:/app:delegated | ||
- /app/node_modules # Keep container's node_modules | ||
environment: | ||
NODE_ENV: development | ||
NUXT_PUBLIC_APP_ENV: development | ||
HOST: "0.0.0.0" | ||
PORT: 3000 | ||
# HMR settings | ||
CHOKIDAR_USEPOLLING: "true" | ||
WATCHPACK_POLLING: "true" | ||
VITE_HMR_HOST: "localhost" | ||
VITE_HMR_PORT: 24678 | ||
# API settings | ||
NUXT_PUBLIC_APP_URL_BASE: "http://localhost" | ||
NUXT_PUBLIC_API_BASE: "http://localhost/api" | ||
extra_hosts: | ||
- "host.docker.internal:host-gateway" | ||
ports: | ||
- "3000:3000" # Main dev server | ||
- "24678:24678" # Vite HMR port | ||
|
||
ingress: | ||
volumes: | ||
- ./docker/nginx.dev.conf:/etc/nginx/templates/default.conf.template | ||
environment: | ||
NGINX_HOST: localhost | ||
NGINX_PORT: 80 | ||
ports: | ||
- "80:80" | ||
depends_on: | ||
- api | ||
- ui | ||
|
||
api-worker: | ||
<<: *api-base | ||
environment: | ||
IS_API_WORKER: "true" | ||
depends_on: | ||
db: | ||
condition: service_healthy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.