Skip to content

Commit

Permalink
add new dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
mfranzon committed Nov 6, 2023
1 parent 780fc6c commit cc4d114
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 17 deletions.
33 changes: 33 additions & 0 deletions docker-ready-to-go/fastapi_container/fastapi.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Use the official Python base image
FROM python:latest

# Get environment variables
ARG app_port=8000
ARG author="Your name"
ARG version="1.0"

ENV APP_HOST=0.0.0.0
ENV APP_PORT=${app_port}

# Set the working directory in the container
WORKDIR /app

# Copy the requirements file to the working directory
COPY requirements.txt .

# Install the dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the application code to the working directory
COPY . .

# Expose the port on which the application will run
EXPOSE ${APP_PORT}

# Set the entrypoint command to run the FastAPI application
CMD ["uvicorn", "main:app", "--host", "${APP_HOST}", "--port", "${APP_PORT}"]

# Add labels for better maintainability
LABEL maintainer=${author}
LABEL version=${version}
LABEL description="Dockerfile for running a FastAPI application"
10 changes: 5 additions & 5 deletions docker-ready-to-go/node_container/node.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ ARG node_env=production
ARG author="Your name"
ARG version="1.0"

ENV PORT=$port
ENV NODE_ENV=$node_env
ENV PORT=${port}
ENV NODE_ENV=${node_env}

# Expose the port on which the application will listen
EXPOSE $port
EXPOSE ${port}

# Set a default command to run the application
CMD ["node", "index.js"]

# Add labels for better maintainability
LABEL maintainer=$author
LABEL version=$version
LABEL maintainer=${author}
LABEL version=${version}
LABEL description="Dockerfile for running a Node.js application"
8 changes: 4 additions & 4 deletions docker-ready-to-go/node_container/react.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ ARG react_default_value
ARG author="Your name"
ARG version="1.0"

ENV REACT_APP_API_URL=$react_url
ENV REACT_APP_API_URL=${react_url}

# Expose the port that the React application will run on
EXPOSE $port
EXPOSE ${port}

# Start the React application
CMD ["npm", "start"]

# Add labels for better maintainability
LABEL maintainer=$author
LABEL version=$version
LABEL maintainer=${author}
LABEL version=${version}
LABEL description="Dockerfile for running a React.js application"
8 changes: 4 additions & 4 deletions docker-ready-to-go/node_container/svelte.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ RUN npm run build
EXPOSE $port

# Set the environment variables for configuration
ENV NODE_ENV=$node_env
ENV NODE_ENV=${node_env}
ENV PORT=5000

# Set a default value for the environment variable
ENV API_URL=$svelte_url
ENV API_URL=${svelte_url}

# Start the application
CMD ["npm", "start"]

# Add labels for better maintainability
LABEL maintainer=$author
LABEL version=$version
LABEL maintainer=${author}
LABEL version=${version}
LABEL description="Dockerfile for running a Node.js application"
8 changes: 4 additions & 4 deletions docker-ready-to-go/node_container/vue.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ ARG version="1.0"
RUN npm run build

# Set the environment variable for the Vue application
ENV VUE_APP_API_URL=$vue_url
ENV VUE_APP_API_URL=${vue_url}

# Expose the port that the Vue application will run on
EXPOSE $port
EXPOSE ${port}

# Start the Vue application
CMD ["npm", "run", "serve"]

# Add labels for better maintainability
LABEL maintainer=$author
LABEL version=$version
LABEL maintainer=${author}
LABEL version=${version}
LABEL description="Dockerfile for running a Vue.js application"
45 changes: 45 additions & 0 deletions docker-ready-to-go/php_container/php.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Use the official PHP image as the base image
FROM php:latest

# Set the working directory inside the container
WORKDIR /var/www/html

# Copy the PHP application files to the container
COPY . .

# Install any necessary dependencies
RUN apt-get update && apt-get install -y \
git \
zip \
unzip

# Install PHP extensions
RUN docker-php-ext-install pdo_mysql

# Get environment variables
ARG author="Your name"
ARG version="1.0"

ARG mysql_host=localhost
ARG mysql_port=3306
ARG mysql_database=myapp
ARG mysql_user=root
ARG mysql_password=secret

# Set environment variables for configuration
ENV MYSQL_HOST=${mysql_host} \
MYSQL_PORT=${mysql_port} \
MYSQL_DATABASE=${mysql_database} \
MYSQL_USER=${mysql_user} \
MYSQL_PASSWORD=${mysql_password}

# Expose port 80 for the web server
EXPOSE 80

# Set a default command to run when the container starts
CMD ["php", "-S", "0.0.0.0:80"]

# Add labels for better maintainability
LABEL maintainer=${author}
LABEL version=${version}
LABEL description="Dockerfile for running a FastAPI application"
29 changes: 29 additions & 0 deletions docker-ready-to-go/rust_container/rust.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Use the official Rust image as the base image
FROM rust:latest

# Get environment variables for configuration
ARG app_port=8080

ENV APP_PORT=${app_port}
ENV APP_HOST=0.0.0.0

# Set the working directory inside the container
WORKDIR /app

# Copy the Cargo.toml and Cargo.lock files to the working directory
COPY Cargo.toml Cargo.lock ./

# Build the dependencies of the Rust application
RUN cargo build --release

# Copy the source code to the working directory
COPY src ./src

# Build the Rust application
RUN cargo build --release

# Expose the port on which the application will listen
EXPOSE $APP_PORT

# Set the command to run the Rust application
CMD ["cargo", "run", "--release"]

0 comments on commit cc4d114

Please sign in to comment.