-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
31 additions
and
47 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,20 @@ | ||
# Use the official Node.js Alpine image as the base image | ||
FROM node:alpine | ||
FROM node:14-alpine | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Install Python and build essentials | ||
RUN apk add --no-cache python3 make g++ | ||
|
||
# Add the MongoDB repository key | ||
RUN wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | apk add --no-cache gnupg && gpg --import - | ||
|
||
# Add the MongoDB repository to APT sources | ||
RUN echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/5.0 main" > /etc/apk/repositories | ||
|
||
# Install MongoDB and MongoDB tools | ||
RUN apk update && apk add --no-cache mongodb-org | ||
|
||
# Create a directory for MongoDB data and logs | ||
RUN mkdir -p /data/db /var/log/mongodb | ||
|
||
# Initialize the data directory and set permissions | ||
RUN mongod --fork --logpath /var/log/mongodb/mongod.log --dbpath /data/db --smallfiles --port 27017 && \ | ||
sleep 5 && \ | ||
mongo admin --eval "db.createUser({ user: 'admin', pwd: 'password', roles: [ 'root' ] });" | ||
|
||
# Install OpenRC, which is used to manage system services (Alpine Linux uses OpenRC) | ||
RUN apk add --no-cache openrc | ||
# Copy package.json and package-lock.json | ||
COPY server/package.json server/package-lock.json ./ | ||
|
||
# Enable MongoDB to start at boot | ||
RUN rc-update add mongodb default | ||
# Install dependencies | ||
RUN npm install --production | ||
|
||
# Expose the port that your Node.js Express app listens on (e.g., 3000) | ||
EXPOSE 5000 | ||
|
||
# Install Node.js packages and your application | ||
COPY server/package.json server/package-lock.json ./ | ||
RUN npm install --production | ||
|
||
# Copy the rest of your application code | ||
COPY . . | ||
|
||
# Start MongoDB and your server | ||
CMD rc-service mongodb start && node src/index.js | ||
# Start your Node.js server | ||
CMD ["npm", "start"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
# use version 3 | ||
version: "3" | ||
version: '3' | ||
|
||
services: | ||
node-app: | ||
build: . | ||
ports: | ||
- "5000:5000" | ||
environment: | ||
- PORT=5000 | ||
server: | ||
build: | ||
context: . | ||
dockerfile: ./server/Dockerfile | ||
args: | ||
- ARCH=amd64 | ||
image: idenmorisha/safe-courier-backend:latest | ||
depends_on: | ||
- mongo | ||
|
||
# MongoDB | ||
mongo: | ||
image: mongo:3.6 | ||
environment: | ||
- MONGO_INITDB_ROOT_USERNAME=root | ||
- MONGO_INITDB_ROOT_PASSWORD=s3cr3tpwd | ||
image: mongo:latest | ||
ports: | ||
- "27017:27017" | ||
volumes: | ||
- mongo-db:/data/db | ||
- mongo_data:/data/db | ||
|
||
# Uncomment the following section if you want to include the 'client' service | ||
# client: | ||
# build: | ||
# context: . | ||
# dockerfile: ./client/Dockerfile | ||
# args: | ||
# - ARCH=amd64 | ||
# image: idenmorisha/safe-courier-frontend:latest | ||
|
||
redis: | ||
image: redis:3.2 | ||
volumes: | ||
mongo-db: | ||
mongo_data: |