Skip to content

Commit

Permalink
chore: Update Dockerfile to remove backend folder and optimize image …
Browse files Browse the repository at this point in the history
…size
  • Loading branch information
nilgaar committed Jul 19, 2024
1 parent aba6253 commit 66731a9
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
2 changes: 2 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
2 changes: 1 addition & 1 deletion backend/run_backend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ docker build -t $APP_NAME .
docker run -d --name $APP_NAME -p 8080:8080 $APP_NAME

cd ..
rm -rf ./backend
rm -rf ./frontend
26 changes: 19 additions & 7 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
# Use an official Node.js runtime as a parent image
FROM node:16

FROM node:14 AS build-stage
# Set the working directory in the container
WORKDIR /app
COPY package*.json ./

# Copy the current directory contents into the container at /app
COPY . /app

# Install dependencies
RUN npm install
COPY . .

# Build your app for production
RUN npm run build
FROM nginx:alpine
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

# Install a simple HTTP server to serve your static content
RUN npm install -g http-server

# Make port 8080 available to the world outside this container
EXPOSE 8080

# Serve the app
CMD ["http-server", "dist", "-p 8080"]
20 changes: 20 additions & 0 deletions frontend/run_frontent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
export DOCKER_BUILDKIT=1

# Name of your Docker application
APP_NAME="vuetify-app"

# Stop the currently running container
docker stop $APP_NAME

# Remove the stopped container
docker rm $APP_NAME

# Build the new Docker image
docker build -t $APP_NAME .

# Run the new Docker container
docker run -d --name $APP_NAME -p 8080:82 $APP_NAME

cd ..
rm -rf ./backend

0 comments on commit 66731a9

Please sign in to comment.