Skip to content

Commit

Permalink
Docker updates (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
spinsager authored Jan 2, 2022
1 parent cc35211 commit 13c458d
Show file tree
Hide file tree
Showing 7 changed files with 3,321 additions and 17 deletions.
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
node_modules
npm-debug.log
.git
.gitignore
README.md
Dockerfile*
.vscode
.travis.yml
README.md
.dockerignore
docker-compose.yml
request.http
nodemon.json
data
.github
8 changes: 4 additions & 4 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SERVER_PORT=3001
DB_NAME=contacts
DB_HOST=localhost
DB_USER=root
DB_PASS=root
DB_PORT=3306
DB_HOST=appDb
DB_USER=appUser
DB_PASS=appUser
DB_PORT=3306
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,5 @@ dist

# TernJS port file
.tern-port

data/
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM node:16-alpine

WORKDIR /usr/src/app

COPY package*.json ./
RUN npm install
COPY . .

EXPOSE 3001
CMD [ "npm", "start" ]
4 changes: 2 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ server.register(require('./src/plugins/db'));
server.register(require('./src/routes'));

const startSever = async () => {
await server.ready()
server.listen(process.env.SERVER_PORT, (err) => {
await server.ready();
server.listen(process.env.SERVER_PORT, '0.0.0.0', (err) => {
if (err) {
server.log.error(err);
process.exit(1);
Expand Down
26 changes: 26 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: "3.9"
services:
api:
container_name: fastify-api
build:
context: .
dockerfile: Dockerfile
image: fastify-api
restart: always
ports:
- "3001:${SERVER_PORT}"
links:
- appDb
appDb:
container_name: appDb
image: mysql:latest
restart: always
environment:
MYSQL_DATABASE: ${DB_NAME}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_PASS}
MYSQL_RANDOM_ROOT_PASSWORD: yes
volumes:
- ./data:/var/lib/mysql
ports:
- "3307:${DB_PORT}"
Loading

0 comments on commit 13c458d

Please sign in to comment.