Created
January 15, 2024 17:47
-
-
Save acedesigns/e221fe59c26946ac42e569bc19c9b04a to your computer and use it in GitHub Desktop.
Create a Dockefile Image and Start It
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
# syntax=docker/dockerfile:1 | |
FROM ubuntu:20.04 | |
LABEL org.opencontainers.image.authors="Anele 'ace' M <anele@acedesigns.co.za>" | |
LABEL version="1.0" | |
LABEL "com.acemedia.vendor"="Ace Media Incorporated" | |
LABEL description="ace Media Docker Image to build PHP, NODE APPS" | |
# replace shell with bash so we can source files | |
RUN rm /bin/sh && ln -s /bin/bash /bin/sh | |
ENV DEBIAN_FRONTEND noninteractive | |
RUN apt-get update \ | |
&& apt -y install software-properties-common curl wget ufw build-essential git libssl-dev unzip php-cli \ | |
&& add-apt-repository ppa:ondrej/php \ | |
&& apt-get -y autoclean | |
# Install PHP | |
RUN apt -y install php7.4 | |
RUN apt-get install -y php7.4-cli php7.4-json php7.4-common php7.4-mysql php7.4-zip php7.4-gd php7.4-mbstring php7.4-curl php7.4-xml php7.4-bcmath | |
# Install / Configure Apache2 | |
RUN apt -y install apache2 | |
RUN ufw allow 'Apache' | |
# Install Composer | |
RUN apt -y install php-cli unzip | |
RUN cd ~ | |
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | |
RUN php -r "if (hash_file('sha384', 'composer-setup.php') === 'e21205b207c3ff031906575712edab6f13eb0b361f2085f1f1237b7126d785e826a450292b6cfd1d64d92e6563bbde02') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" | |
RUN php composer-setup.php | |
RUN php -r "unlink('composer-setup.php');" | |
RUN mv composer.phar /usr/local/bin/composer | |
RUN composer -V | |
# Install MySql | |
#SHELL ["/bin/bash", "--login", "-i", "-c"] | |
#RUN apt -y install mysql-server | |
#RUN mysql && ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; && exit | |
#SHELL ["/bin/bash", "--login", "-i", "-c"] | |
# Innstall MongoDb | |
RUN \ | |
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 && \ | |
echo "deb [arch=amd64] http://repo.mongodb.org/apt/ubuntu $(lsb_release -sc)/mongodb-org/5.0 multiverse" | tee /etc/apt/sources.list.d/mongodb.list \ | |
apt-get update && \ | |
apt install -y mongodb && \ | |
rm -rf /var/lib/apt/lists/* | |
# Define mountable directories. | |
VOLUME ["/data/db"] | |
# Define working directory. | |
WORKDIR /data | |
# Define default command. | |
#CMD ["mongod"] | |
# Expose ports. | |
EXPOSE 27017:27017 | |
# Install Node | |
RUN mkdir -p /usr/local/nvm | |
ENV NVM_DIR /usr/local/nvm | |
ENV NODE_VERSION 18.15.0 | |
#SHELL [ "/bin/bash", "-login", "-i", "-c" ] | |
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash | |
RUN source $NVM_DIR/nvm.sh \ | |
&& nvm install $NODE_VERSION \ | |
&& nvm alias default $NODE_VERSION \ | |
&& nvm use default | |
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules | |
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH | |
RUN node -v && npm -v | |
RUN npm i -g yarn | |
# RUN APP | |
#COPY api /apps/api | |
WORKDIR /apps/api | |
COPY api/package.json api/package-lock.json ./ | |
RUN npm install | |
COPY api/ . | |
EXPOSE 8083 | |
CMD [ "npm", "start", "mongod"] |
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
https://github.com/nvm-sh/nvm/blob/master/Dockerfile | |
https://stackoverflow.com/questions/51174516/ | |
https://semaphoreci.com/community/tutorials/dockerizing-a-node-js-web-application | |
https://stackoverflow.com/questions/25899912/ | |
docker ps | |
docker ps -aq | xargs docker stop | xargs docker rm | |
docker run -it -p 3000:3000 imagename | |
docker restart <container-id> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment