-
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.
Containerize backend app and MySQL database. (#230)
* Containerize backend and, integrate with MySQL container using docker-compose. * Add default password to compose environment * Update documentation to include Docker * Update documentation headers and command outline * Update docker documentation to have bolder commands * Add warning about Docker container volume * Modify init.sql to use legacy authentication * Modify .env.example default values to be consistent * Assign db.config.js values to be consistent with .env.example * Add legacy authentication to MySQL * Update .env dev database name * Remove mysql_native_password option in init.sql in favor of configuration option.
- Loading branch information
1 parent
9a470d0
commit 07e1c60
Showing
8 changed files
with
218 additions
and
37 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
npm-debug.log | ||
Dockerfile | ||
.dockerignore |
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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Use the official Node.js image as a base image | ||
FROM node:latest | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy package.json and package-lock.json files to the working directory | ||
COPY package*.json ./ | ||
|
||
# Install the dependencies | ||
RUN npm install | ||
|
||
# Copy the rest of the application code to the working directory but ignore node_modules | ||
COPY . . | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 3001 | ||
|
||
# Command to run the application | ||
CMD ["npm", "run", "start:dev"] |
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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
version: "3.8" | ||
|
||
services: | ||
backend: | ||
container_name: myclassroom_backend | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
environment: | ||
DEV_DB_HOST: db | ||
DEV_DB_PASS: password | ||
TEST_DB_HOST: db | ||
TEST_DB_PASS: password | ||
entrypoint: ["./entrypoint.sh"] | ||
ports: | ||
- "3001:3001" | ||
expose: | ||
- "3001" | ||
|
||
db: | ||
image: mysql:latest | ||
container_name: myclassroom_db | ||
command: ["mysqld", "--mysql-native-password=ON"] | ||
environment: | ||
MYSQL_ROOT_PASSWORD: rootpassword | ||
ports: | ||
- "3306:3306" | ||
volumes: | ||
- db_data:/var/lib/mysql | ||
- ./db/init.sql:/docker-entrypoint-initdb.d/init.sql | ||
healthcheck: | ||
test: ["CMD-SHELL", "mysqladmin ping -h localhost -u root -prootpassword"] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
|
||
volumes: | ||
db_data: |
Oops, something went wrong.