Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No such file or directory when running migrate install on windows #51

Open
ga0357r opened this issue Jan 9, 2024 · 6 comments
Open

Comments

@ga0357r
Copy link

ga0357r commented Jan 9, 2024

whenever I run vendor/bin/migrate install --path vendor/byjg/migration-cli/pob/sql_server sqlsrv://user_id:'userpwd'@sql1/DB-v in windows docker php container environment, it gives me this error vendor/bin/migrate: line 1: ../byjg/migration-cli/scripts/migrate: No such file or directory. This is the vendor/bin/migrate script ../byjg/migration-cli/scripts/migrate.

However, this works on mac docker php container environment with no issues. Does anyone know how I can fix this, thank you.

@byjg
Copy link
Owner

byjg commented Jan 9, 2024

Are you running this command on WSL2 under Linux Terminal, or on PowerShell / Command Prompt?

Another point to observe: The current stable version is ^4.9. Make sure you are on that version.

@ga0357r
Copy link
Author

ga0357r commented Jan 9, 2024

I run it on vscode powershell
image

@ga0357r
Copy link
Author

ga0357r commented Jan 9, 2024

I am also using version 4.2
image

@byjg
Copy link
Owner

byjg commented Jan 10, 2024

I believe the issue is in the Docker container, you are running the command line. Would you mind sharing the docker file/ docker-compose you are using?

@ga0357r
Copy link
Author

ga0357r commented Jan 10, 2024

alright, this is the docker compose and php dockerfile as well.

docker compose file

version: '3.3'

services:
    web:
        build: 
          context: .
          dockerfile: ./nginx/Dockerfile
        ports:
            - "52379:80"
            - "8080:8080"
            - "5173:5173"
        volumes:
            - ./code:/code
            - ./src:/src
            - ./nginx/site.conf:/etc/nginx/conf.d/default.conf
        networks:
            - code-network
    php:
        build:
            context: .
            dockerfile: php/develop/Dockerfile
        volumes:
            - ./code:/code
            - ./src:/src
            - ./etc/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/zzz-www.conf
        networks:
            - code-network
    db:
        build:
            context: .
            dockerfile: sqlserver/Dockerfile
        volumes:
            - ./storage/backup:/backup
        ports:
            - "1433:1433"
        networks:
            code-network:
        container_name: sql1
        hostname: sql1
    backup:
        build:
            context: .
            dockerfile: backup-system/Dockerfile
        volumes:
            - ./storage/backup:/backup
        networks:
            code-network:
    mailhog:
      image: mailhog/mailhog
      ports:
        - target: 8025
          published: ${MAILHOG_PUBLISHED_PORT:-8025}
          protocol: tcp
          mode: host
      networks:
        - code-network

networks:
    code-network:
        driver: bridge

php dockerfile

FROM php:8.2-fpm-bullseye
WORKDIR /code

# setup composer environment variables
ENV COMPOSER_ALLOW_SUPERUSER=1 \
  COMPOSER_HOME=/composer

# use composer within php container
COPY --from=composer:2.6 /usr/bin/composer /usr/bin/composer

# Change listen port from www.conf
COPY ./etc/php-fpm.d/www.conf /usr/local/etc/php-fpm.d/zzz-www.conf
# copy php.ini
COPY ./etc/php/develop/php.ini /usr/local/etc/php/
COPY ./etc/php/develop/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini

# Get repository and install wget and vim
RUN apt-get update && apt-get install -y \
  wget \
  apt-utils \
  gnupg \
  software-properties-common \
  apt-transport-https \
  libxml2-dev \
  unixodbc-dev

# necessário para sqlsrv 
# Install PHP extensions deps
# Install PHP extensions
# install and enable xdebug
# Clean repository
RUN wget -qO - https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
  && wget -qO - https://packages.microsoft.com/config/debian/11/prod.list \
  > /etc/apt/sources.list.d/mssql-release.list \
  && apt-get update \
  && apt-get install --no-install-recommends -y \
  libfreetype6-dev \
  libjpeg62-turbo-dev \
  libmcrypt-dev \
  libpng-dev \
  zlib1g-dev \
  libicu-dev \
  g++ \
  git \ 
  unzip \
  libzip-dev \
  libonig-dev \
  && ACCEPT_EULA=Y apt-get install --no-install-recommends -y msodbcsql17 mssql-tools \
  libaio-dev \
  libmemcached-dev \
  freetds-dev \
  libssl-dev \
  openssl \
  supervisor \
  && pecl install sqlsrv pdo_sqlsrv \
  && pecl install mcrypt-1.0.6 && docker-php-ext-enable mcrypt \
  && pecl install xdebug-3.2.2 && docker-php-ext-enable xdebug \
  && docker-php-ext-install \
  iconv \
  sockets \
  pdo \
  pdo_mysql \
  intl \
  mbstring \
  zip \ 
  bcmath \
  && docker-php-ext-enable \
  sqlsrv \
  pdo_sqlsrv \
  && apt-get autoremove -y && \
  apt-get clean && \
  rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*

@byjg
Copy link
Owner

byjg commented Jan 10, 2024

Hello,

I am not seeing either you're copying/sharing the vendor folder or you are running the composer install inside the docker file.

The easy way you run the composer install on the windows side and share it inside the docker file. Something like this:

docker-compose.yaml

    php:
        build:
            context: .
            dockerfile: php/develop/Dockerfile
        volumes:
            - ./code:/code
            - ./vendor:/vendor       <------
            - ./src:/src
            - ./etc/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/zzz-www.conf

Docker cannot access the windows files unless you allow that by "sharing" in the volumes part. Also, you need to verify if the folders you're sharing inside the docker are correct.

It isn't an issue on the migrations lib, but on the environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants