Skip to content

Commit

Permalink
feat: gains PROD version of Dockerfile (#16)
Browse files Browse the repository at this point in the history
* rename Dockerfile.dev to Dockerfile

* use nginx server for prod

* update Dockerfile name and ports
  • Loading branch information
jdhoffa authored Jul 29, 2024
1 parent 8483ada commit c1bfbb6
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 30 deletions.
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Build Stage
FROM node:18-alpine AS build

# Set the working directory
WORKDIR /app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install the dependencies
RUN npm install

# Copy necessary configurations to the working directory
COPY postcss.config.cjs ./
COPY svelte.config.js ./
COPY tailwind.config.ts ./
COPY tsconfig.json ./
COPY vite.config.ts ./

# Copy the source code to the working directory
COPY src ./src
COPY static ./static
# COPY .svelte-kit ./.svelte-kit

# Build the application
RUN npm run build

# Production Stage
FROM nginx:alpine

# Copy the built files from the build stage
COPY --from=build /app/build /usr/share/nginx/html

# Copy the nginx configuration file
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Expose the port on which the application will run
EXPOSE 8080

# Start nginx server
CMD ["nginx", "-g", "daemon off;"]
28 changes: 0 additions & 28 deletions Dockerfile.dev

This file was deleted.

4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ services:
svelte-app:
build:
context: .
dockerfile: Dockerfile.dev
dockerfile: Dockerfile
ports:
- '3000:3000'
- '8080:8080'
volumes:
- type: bind
source: ${JSON_ASSETS_PATH}
Expand Down
14 changes: 14 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
server {
listen 8080;
server_name localhost;

location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

0 comments on commit c1bfbb6

Please sign in to comment.