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

Dev docker wrapper #7

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open

Dev docker wrapper #7

wants to merge 27 commits into from

Conversation

spamoom
Copy link
Contributor

@spamoom spamoom commented May 20, 2021

Introduces the Dockerfile and a bundled wrapper for running and managing.

Only changes to actual CLI code are removing the need to use .ssh and making use of the local image directory as well as dropping support for docker-compose and using the new built in docker compose

Due to the docker compose change, this will be tagged as a major version bump

@spamoom spamoom requested a review from kubatek94 May 20, 2021 10:41
@spamoom
Copy link
Contributor Author

spamoom commented May 20, 2021

Ah crap, hold fire. SSH tunnels don't work 😂

Copy link
Contributor

@kubatek94 kubatek94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job all around @spamoom, will be very useful!

Other than the comments already added, the major problem I have is that the docker compose command is not available in stable docker releases yet, so while I am up to date on docker, unless I switch to testing/edge, it's not going to work for me.

What do you think of using docker-compose for the time being (keeping the same major NS CLI version), and then doing the switch to just docker once the feature lands in stable?

Another thing I just thought about. Does the AWS ECR access work properly?
When we run the docker:aws:login command, that then runs the docker login command, which stores the auth token in ~/.docker/config.json - is this written to the host or the container? And also, is this file read by the CLI or the daemon? Depending on those, it could work or it wouldn't. I have hard time checking that though due to the lack of docker compose on my machine.

##
# PHP Runtime
##
FROM php:7.4-cli as runtime
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can do few tweaks here to make the resulting image considerably smaller, and also to make the self-update pull down only the things that changed. Are you ok for me to look into it later on in the evening?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely mate - I was doing this between meetings so it's very WIP - just wanted it in front of you as I knew you'd spot a load of improvements

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, will try few ideas and report back :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done few tweaks to reduce the image by > 300MB. It's still big, but at least it has all tools inside it which is convenient.

ECR helper works well after a fix which is great, however worth testing again on TeamCity, as it won't have access to the AWS config file I think?

I do have problems using the SSM connect feature, but not sure if it's just all our EC2 instances not having it enabled or something? Would be nice if you can confirm it's working.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work - yeah the NS EC2 images aren't setup for SSM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already checked on the YPS Teamcity agent, it's able to access the meta domain so is able to get auth 🌮

http://169.254.169.254/latest/meta-data/

@spamoom
Copy link
Contributor Author

spamoom commented May 20, 2021

Thinking further about this - I think it might be wise to drop non docker usage all together- thoughts?

@kubatek94
Copy link
Contributor

Thinking further about this - I think it might be wise to drop non docker usage all together- thoughts?

If we manage to get all features to work, I don't see why not. We could then have the whole netsells CLI installer from now.sh just install the wrapper script. However I think I would wait with this until we don't need docker-compose and can just do full major release.

--rm \
--init \
-it \
-v 'sshvol:/root/.ssh' \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is still required, given we now store the key in tmp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't sync with the local ssh, it just uses a volume to persist the known_hosts file so you don't have to type yes every time you connect to the same server

@NickSnellockNS
Copy link
Contributor

NickSnellockNS commented Jul 1, 2021

This is the Dockerfile I created for testing:


RUN apt-get update && apt-get install -y \
        zsh \
        vim \
        cron \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng-dev \
        libicu-dev \
        libpq-dev \
        libxpm-dev \
        libvpx-dev \
        libzip-dev \
        libwebp-dev \
        libxml2-dev \
        gnupg \
        gnupg1 \
        gnupg2 \
        wget \
        unzip \
        git \
        iputils-ping \
        iproute2 \
        tar

RUN wget http://www.xmailserver.org/libxdiff-0.22.tar.gz && \
    tar -xzf libxdiff-0.22.tar.gz && \
    cd libxdiff-0.22 && \
    ./configure && \
    make && \
    make install && \
    cd .. && \
    rm -rf libxdiff-0.22 && \
    rm libxdiff-0.22.tar.gz

RUN echo '' | pecl install xdiff

RUN pecl install xdebug && docker-php-ext-enable xdebug \
    && docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd \
    && docker-php-ext-install -j$(nproc) intl \
    && docker-php-ext-install -j$(nproc) zip \
    && docker-php-ext-install -j$(nproc) exif \
    && docker-php-ext-install -j$(nproc) pcntl \
    && docker-php-ext-install -j$(nproc) bcmath

COPY resources/php.ini /usr/local/etc/php/php.ini

RUN pear config-set php_ini /usr/local/etc/php/php.ini

# Xdebug 3
RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
    && echo "xdebug.log_level=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

WORKDIR /var/www

# Install composer
COPY resources/install_composer.sh /root/
COPY resources/composer /usr/local/bin/

RUN chmod 755 /root/install_composer.sh && mkdir /var/www/storage && mkdir /var/www/storage/logs && /root/install_composer.sh

RUN chmod 755 /usr/local/bin/composer && chmod 755 /usr/local/etc/php/composer.phar

RUN mkdir /home/root && chmod 777 /home/root

ENV HOME /home/root

RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
    unzip awscliv2.zip && \
    ./aws/install

@probot-netsells
Copy link

Uh oh!

Looks like this PR has some conflicts with the base branch, @spamoom.

Please bring your branch up to date as soon as you can.

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

Successfully merging this pull request may close these issues.

3 participants