--- title: "Example App with Dockerfile Build" description: "Deploy an application using a custom Dockerfile on Miget." --- This guide walks you through deploying an application on Miget using a custom Dockerfile. ## Prerequisites Before you start, ensure you have: 1. **Miget Account** - Register at [Miget](https://app.miget.com/apps). 2. **Git installed** - You need Git to push your code to Miget. 3. **A Dockerfile** - Your application should have a Dockerfile in the repository root. ## Create a Miget App 1. In the Miget dashboard, click [**New**](https://app.miget.com/apps/new) to create a new app. 2. Choose your preferred settings and give your app a name. ## Configure the Builder 1. Navigate to **Settings → Builders**. 2. Set the Builder to **Dockerfile**. This tells Miget to use your Dockerfile for building the application instead of auto-detecting a buildpack. ## Prepare Your Dockerfile Ensure your Dockerfile is in the root of your repository. Here's a simple example for a Node.js application: ```dockerfile FROM node:20-alpine WORKDIR /app COPY package*.json ./ RUN npm ci --only=production COPY . . EXPOSE 3000 CMD ["node", "server.js"] ``` ### Best Practices - **Use multi-stage builds** to reduce image size - **Specify exact versions** for base images - **Use `.dockerignore`** to exclude unnecessary files - **Run as non-root user** for security Example multi-stage build: ```dockerfile # Build stage FROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build # Production stage FROM node:20-alpine WORKDIR /app COPY --from=builder /app/dist ./dist COPY --from=builder /app/node_modules ./node_modules EXPOSE 3000 USER node CMD ["node", "dist/server.js"] ``` ## Deploy Your Application 1. Go to the **Deploy** tab in your app dashboard. 2. Copy the Git remote URL provided. 3. Add the remote and push your code: ```bash git remote add miget https://git.eu-east-1.miget.io// git push miget main ``` Replace `` and `` with your actual Miget workspace and app name. Miget will build your Docker image and deploy it automatically. ## Environment Variables If your application requires environment variables: 1. Go to **Settings → Config Vars**. 2. Click **Edit Config Vars**. 3. Add your environment variables. These will be available to your application at runtime. ## Viewing Logs Monitor your application's build and runtime logs: 1. Go to the **Logs** tab in your app dashboard. 2. View build logs during deployment. 3. View runtime logs once the app is running. ## Summary By using a Dockerfile, you have full control over your application's build process and runtime environment. This is useful for applications with specific dependencies or custom build steps that aren't supported by standard buildpacks.