Based on the provided docker-compose file, here are the steps to use Docker Compose to create and build your own Docker image qcobjects_newapp:
-
Create a Dockerfile: Ensure you have a
Dockerfilein your project directory with the following content:FROM qcobjects/qcobjects:latest USER root ENV XDG_RUNTIME_DIR $(id -u) ENV container docker ENV LC_ALL C ENV DEBIAN_FRONTEND noninteractive LABEL MAINTAINER "Jean Machuca <jean@qcobjects.com>" LABEL Author "Jean Machuca <jean@qcobjects.com>" LABEL org.opencontainers.image.authors="Jean Machuca <jean@qcobjects.com>" ENV container docker RUN npm i -g qcobjects qcobjects-sdk qcobjects-cli # Configure the internal user permissions RUN mkdir -p /home/qcobjects/app && chown -R qcobjects:qcobjects /home/qcobjects/app # Setting the work directory WORKDIR /home/qcobjects/app ENV DOCUMENT_ROOT /home/qcobjects/app/ ENV DATA_PATH $DOCUMENT_ROOT/data/ COPY package*.json ./ # Run the initial install init scripts for jasmine and cache verify # RUN jasmine init RUN npm cache verify RUN npm i # Bundle app source COPY --chown=qcobjects:qcobjects . . USER qcobjects EXPOSE 8080:8080 EXPOSE 8443:8443 CMD [ "npm", "start" ]
-
Create a
docker-compose.ymlFile: Create adocker-compose.ymlfile in your project directory with the following content:version: '3' services: qcobjects: image: qcobjects_newapp:latest hostname: qcobjects_newapp command: ["npm", "run", "start"] privileged: true build: context: ./ dockerfile: Dockerfile volumes: - ./letsencrypt:/etc/letsencrypt/live/newapp.qcobjects.dev - ./data:/home/qcobjects/app/data expose: - 8080:8080 - 8443:8443 - 10300:10300 ports: - 8080:8080 - 8443:8443 - 10300:10300 env_file: - ./.env
-
Environment Variables: Create a
.envfile in your project directory to define environment variables. This file might include variables such as:NODE_ENV=production PORT=8080 SSL_PORT=8443
-
Build and Run the Docker Compose Setup: Open a terminal in your project directory and run the following commands:
# Build the Docker image docker-compose build # Start the services docker-compose up
NODE_ENV: Specifies the environment in which the application is running (e.g.,development,production).PORT: The port on which the application will run (default is8080).SSL_PORT: The port for SSL connections (default is8443).
./letsencrypt:/etc/letsencrypt/live/newapp.qcobjects.dev: Maps the localletsencryptdirectory to the container's directory for SSL certificates../data:/home/qcobjects/app/data: Maps the localdatadirectory to the container's data directory.
8080:8080: Maps port8080on the host to port8080in the container.8443:8443: Maps port8443on the host to port8443in the container.10300:10300: Maps port10300on the host to port10300in the container.
These steps will help you set up and run your QCObjects application using Docker Compose, ensuring a consistent and efficient development environment.