Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment - dockerizing web server and database #12

Open
stevenabreu7 opened this issue Apr 13, 2019 · 0 comments
Open

Deployment - dockerizing web server and database #12

stevenabreu7 opened this issue Apr 13, 2019 · 0 comments
Assignees

Comments

@stevenabreu7
Copy link
Member

For the web server, I have the following dockerfile (which is in the repo's root directory). It basically copies all server files to the docker container, then installs packages and runs the server (by default on port 3000) and exposes port 3000 to outside of the docker container.

FROM node:alpine

WORKDIR /usr/src/app

COPY . ./

RUN npm install
RUN npm run build-ts

EXPOSE 3000

CMD ["npm", "start"]

which I build and run with the following:

docker build -t tc-web .
docker run -d -p 3000:3000 --name tc-web tc-web

For the database, I have the following dockerfile. You can change the COPY ./sql-scripts/ ... to wherever the create_db.sql script is (and any other SQL scripts that should be executed when the container is started).

FROM mysql:5

ENV MYSQL_DATABASE JacobsApp
ENV MYSQL_ROOT_PASSWORD root

COPY ./sql-scripts/ /docker-entrypoint-initdb.d/

This one I run with

docker build -t tc-mysql .
docker run -d -p 3306:3306 --name tc-mysql tc-mysql

Feel free to use or change these dockerfiles as you see fit.

So the task now is:

  • write a docker compose script that runs web server and database in a way that the server can read the database.
  • make sure changes to the database are persisted somehow - so we don't lost any data when the docker container is stopped (probably by mounting a volume to the docker container).
  • clean up the repository with the new docker config files and make a pull request!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants