Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Placing a git repo into docker on a Windows 10 laptop

  • 12-09-2019 1:25pm
    #1
    Registered Users, Registered Users 2 Posts: 5,659 ✭✭✭


    Ive completed my coding of a Java app and wish to put it into Docker as it uses mysql etc.

    I have a github repo and know how to do my git pull etc normally. How do i make it do this within a Docker container though? Im playing around with it on Docker Quickstart Terminal.

    Ive taken a Dockerfile sample but it references Ubuntu which im not using so id guess it needs changes. The git clone command is thein but im not sure if this is the right spot for it.


    # Dockerfile
    
    FROM  phusion/baseimage:0.9.17
    
    MAINTAINER  Author Name <author@email.com>
    
    RUN echo "deb http://archive.ubuntu.com/ubuntu trusty main universe" > /etc/apt/sources.list
    
    RUN apt-get -y update
    
    RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q python-software-properties software-properties-common
    
    ENV JAVA_VER 8
    ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
    
    RUN echo 'deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main' >> /etc/apt/sources.list && \
        echo 'deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main' >> /etc/apt/sources.list && \
        apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C2518248EEA14886 && \
        apt-get update && \
        echo oracle-java${JAVA_VER}-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections && \
        apt-get install -y --force-yes --no-install-recommends oracle-java${JAVA_VER}-installer oracle-java${JAVA_VER}-set-default && \
        apt-get clean && \
        rm -rf /var/cache/oracle-jdk${JAVA_VER}-installer
        git clone https://github.com/rappsApps/shortcuts.git
    
    RUN update-java-alternatives -s java-8-oracle
    
    RUN echo "export JAVA_HOME=/usr/lib/jvm/java-8-oracle" >> ~/.bashrc
    
    RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
    
    CMD ["/sbin/my_init"]
    


Comments

  • Registered Users, Registered Users 2 Posts: 7,157 ✭✭✭srsly78


    Go to windows store and search for ubuntu :)


  • Registered Users, Registered Users 2 Posts: 2,040 ✭✭✭Colonel Panic


    The Dockerfile references Ubuntu because I'd imagine the base image is derived from Ubuntu. All it's doing is installing some Java stuff.

    Going to the Windows store and searching for Ubuntu won't help here.

    Do you have Docker for Windows installed? If so, you need to use that to build a container from the Dockerfile with additional commands that clone your git repo in it. You then need to specify the entry point you want to run that will start your Java application


  • Registered Users, Registered Users 2 Posts: 5,659 ✭✭✭veryangryman


    The Dockerfile references Ubuntu because I'd imagine the base image is derived from Ubuntu. All it's doing is installing some Java stuff.

    Going to the Windows store and searching for Ubuntu won't help here.

    Do you have Docker for Windows installed? If so, you need to use that to build a container from the Dockerfile with additional commands that clone your git repo in it. You then need to specify the entry point you want to run that will start your Java application

    Using Docker Quickstart Terminal.

    Can you recommend any guides or videos on this for i'm farily new to Docker. Thanks


  • Registered Users, Registered Users 2 Posts: 2,040 ✭✭✭Colonel Panic


    What have you tried so far? There's docs on the Docker site to get you up and running, but at this point, you'll need to have a bit of Linux knowledge. I can't think of any videos, I just used the docs.

    For Java apps, I'd probably checkout and build my code locally as always, then copy the files to the container via a COPY command in the dockerfile, then set up an entry point for the app.

    If you want to use mysql from another docker container then you'd need to have a look at docker compose to build a cluster of containers with shared networking all doing little bits of your app.


  • Registered Users, Registered Users 2 Posts: 6,262 ✭✭✭Buford T Justice


    What the Colnel said. If your app is running mysql and some other services then they should ideally be located in separate containers for local development.

    Are you using maven as a build tool? If so I'd use it to build your jar file and reference that using your Dockerfile

    Could be something as simple as:
    FROM openjdk:11
    
    COPY ./<my-project-name>/target/*-exec.jar app.jar
    
    COPY ./scripts/startup.sh /
    RUN chmod +x startup.sh;
    
    ENTRYPOINT ["sh", "-c", "/startup.sh" ]
    
    ARG SERVER_PORT=8080
    EXPOSE ${SERVER_PORT}
    

    In this case, there's a startup.sh script that basically calls "java -jar app.jar"


  • Advertisement
Advertisement