So I have 2 folders next to each other, "cms" and "project-1".
The "project-1" folder contains the lando file.
I'm trying to mount the cms folder inside the webroot in order to create a proxy for it.
name: project-1
recipe: lamp
config:
webroot: .
proxy:
site:
- project-1-site.lndo.site
cms:
- project-1-cms.lndo.site
services:
webserver:
type: php:7.3
via: apache:2.4
ssl: true
database:
type: mariadb:10.1.47
pma:
type: phpmyadmin
hosts:
- database
site:
type: php:7.3
via: apache:2.4
ssl: true
webroot: /public
build_as_root:
- a2enmod headers
cms:
type: php:7.3
via: apache:2.4
ssl: true
webroot: ../cms
build_as_root:
- a2enmod headers
What would be the best way to achieve this result?
I don't want to move the lando file in the same folder as the "cms" and "project-1" folders.
I have tried the cp command in build_as_root but it seems impossible to target content outside of the folder where the lando file is located.
I used the drupal7 recipe and mounting an outside folder worked for me as follows:
Assuming the following project folder setup:
[parent folder]/lando (this has .lando.yml)
[parent folder]/cms (this has index.php)
The following lando config worked:
name: my-project
recipe: drupal7
config:
webroot: .
services:
appserver:
# Keys 'app_mount' and overrides/volumes allow outside lando folder.
# #see https://docs.lando.dev/compose/config.html
# #see https://github.com/lando/lando/issues/1487#issuecomment-619093192
app_mount: delegated
overrides:
volumes:
- "../cms:/app"
Related
there.
I've been struggling with building Docker(Docker Compose) and Webpack environment for months.
What I want to achieve is hot reloading for a webpack-dev-server running inside a docker container with code changes from outside the container.
Here is what I've been able to do so far...
If you run webpack-dev-server in the container and make changes to the code in the container by the vim editor, the changes will take effect and hot reloading will work.
If you start webpack-dev-server locally while the container is running and make code changes locally too, hot reloading will be performed here as well.
Is anyone familiar with Docker and Webpack? If so, I'd like some advice on how to solve this problem.
Here is my Dockerfile.
# Base image
FROM node:lts-buster-slim
# Create working directory
RUN mkdir -p /app/framer
# Set working directory
WORKDIR /app/framer
# Add $PATH
ENV PATH /app/framer/node_modules/.bin:$PATH
Here is my docker-compose.yml.
version: "3.9"
services:
app:
build:
context: .
dockerfile: Dockerfile
tty: true
volumes:
- ./framer:/app/framer
- /framer/node_modules
expose:
- 3002
ports:
- "3002:3002"
environment:
- WATCHPACK_POLLING=true
- WDS_SOCKET_HOST=127.0.0.1
- WDS_SOCKET_PORT=3002
stdin_open: true
restart: unless-stopped
Here is my webpack-dev-server settings.
devServer: {
open: true,
static: {
directory: path.join(__dirname, 'dist'),
},
host: '0.0.0.0',
allowedHosts: 'all',
hot: true,
port: 3002,
historyApiFallback: true,
client: {
webSocketURL: 'ws://0.0.0.0:3002/ws',
reconnect: true,
overlay: {
errors: true,
warnings: false,
},
},
},
watchOptions: {
poll: true,
},
In addition, I will put a link to the GitHub repository that I'm working on for your reference.
https://github.com/Bear29ers/framer-motion
What I want to achieve is hot reloading for a webpack-dev-server running inside a docker container with code changes from outside the container.
First, enter the container like this.
docker compose exec app bash
Then, run webpack-dev-server.
npm run dev
While running webpack-dev-server inside the container, you change some code in src/ directory from outside the container.
I want the browser that accesses localhost:3002 to detect the change and reload automatically.
Best regards.
I am learning about Volumes in the Kubernetes.
I understood the concept of Volume and types of volume.
But, I am confused about the mouthPath property. Following my YAML file:
apiVersion: v1
kind: Pod
metadata:
name: nginx-alpine-volume
spec:
containers:
- name: nginx
image: nginx:alpine
volumeMounts:
- name: html
mountPath: /usr/share/nginx/html
readOnly: true
resources:
- name: html-updater
image: alpine
command: ["/bin/sh", "-c"]
args:
- while true; do date >> /mohit/index.html;sleep 10; done
resources:
volumeMounts:
- name: html
mountPath: /mohit
volumes:
- name: html
emptyDir: {}
Question: What is the use of the mountPath property. Here, I am using one pod with two containers. Both containers have different mounPath values.
Update:
Consider the mount path as the directory where you are attaching or mounting the files or system
While your actual volume is emptyDir
What basically the idea is there to both container have different mount path
as both containers need to use different folders
While as your volume is single name html so locally from volume both container pointing or using the different folders
both containers manage the different files at their mounting point (or folder)
so mount path is a point or directly where your container will be managing files.
Empty dir : https://kubernetes.io/docs/concepts/storage/volumes/#emptydir
Read more at : https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/
if you see this example: https://github.com/harsh4870/Kubernetes-wordpress-php-fpm-nginx/blob/master/wordpress-deployment.yaml
it has the same two containers with mount path and emptydir volume
what i am doing is attaching the Nginx configuration file, to the container so Nginx will use that configuration file which i am mounting from outside to the container.
My config file stored inside configmap or secret.
How should Mutagen be configured, to synchronise local-host source code files with a Docker volume, onto a Kubernetes cluster?
I used to mount my project directory onto a container, using hostPath:
kind: Deployment
spec:
volumes:
- name: "myapp-src"
hostPath:
path: "path/to/project/files/on/localhost"
type: "Directory"
...
containers:
- name: myapp
volumeMounts:
- name: "myapp-src"
mountPath: "/app/"
but this has permission and symlinks problems, that I need to solve using Mutagen.
At the moment, it works correctly when relying on docker-compose (run via mutagen project start -f path/to/mutagen.yml):
sync:
defaults:
symlink:
mode: ignore
permissions:
defaultFileMode: 0664
defaultDirectoryMode: 0775
myapp-src:
alpha: "../../"
beta: "docker://myapp-mutagen/myapp-src"
mode: "two-way-safe"
But it isn't clear to me how to configure the K8S Deployment, in order to use Mutagen for keeping the myapp-src volume in sync with localhost?
I would like to share a directory from my Windows host to my Kubernetes container, achieving the same what I used to have in docker-compose:
volumes:
- ./data:/mnt/data
I tried with hostPath the following way:
volumes:
- name: data-vol
hostPath:
path: ./data
type: Directory
It failed with "MountVolume.SetUp failed for volume "data-vol" : hostPath type check failed: ./data is not a directory"
I tried with different path formats (e.g: /C/data or /host_mnt/c/data) but no success. Any idea how to overcome this?
Can you try to use absolute path instead relative:
FROM:
path: ./data
type: Directory
TO:
path: /my/absolute/path/data
type: Directory
I am trying to create docker containers with datasource and dashboard already preconfigured.
As of now I can understand that from v5.0 onwards grafana have introduced feature of provisioning.
I have created two yml file first the datasource and second the dashboard.
But I couldn't understand which part of docker-compose file will invoke these datasource.yml and dashboarad.yml file. What tag should I used and so on.Below are my docker-compose, datasource & dashboard file details.
Only detail in compose file I could bit understood is - ./grafana/provisioning/:/etc/grafana/provisioning/ which is copy some host folder structure to container (but not sure about it).
docker-compose.yml
grafana:
image: grafana/grafana
links:
- influxdb
ports:
- '3000:3000'
volumes:
- 'grafana:/var/lib/grafana'
- ./grafana/provisioning/:/etc/grafana/provisioning/
Dashboard.yml
apiVersion: 1
providers:
- name: 'Docker Dashboard'
orgId: 1
folder: ''
type: file
disableDeletion: false
updateIntervalSeconds: 10 #how often Grafana will scan for changed dashboards
options:
path: <path-where-I-have-placed-jsonfile>
Datasource.yml
datasources:
- access: 'proxy' # make grafana perform the requests
editable: true # whether it should be editable
is_default: true # whether this should be the default DS
name: 'influx' # name of the datasource
org_id: 1 # id of the organization to tie this datasource to
type: 'influxdb' # type of the data source
url: 'http://<ip-address>:8086' # url of the prom instance
database: 'influx'
version: 1 # well, versioning
the volumes directive will run only in runtime not build you need to use COPY if you want that to work in build stage
Dockerfile:
FROM grafana/grafana
COPY ./grafana/provisioning /etc/grafana/provisioning
the ./grafana/provisioning should be relative to Dockerfile
Compose:
grafana:
build: .
.
.