Initial Docker Automatisation Work
This commit is contained in:
parent
a0e54a284c
commit
0aa9dffd75
4 changed files with 46 additions and 0 deletions
31
Dockerfile
Normal file
31
Dockerfile
Normal file
|
@ -0,0 +1,31 @@
|
|||
# Builder stage
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
# Set the working directory in the container
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the repository contents into the container
|
||||
COPY . .
|
||||
|
||||
# Install dependencies and build the site. Output directory will be /app/build
|
||||
RUN yarn install && yarn run build
|
||||
|
||||
# No need to move /app/build here
|
||||
|
||||
# Final stage
|
||||
FROM caddy:2-alpine
|
||||
|
||||
# Set the working directory in the container
|
||||
WORKDIR /web
|
||||
|
||||
# Copy the build directory from the builder stage to /web
|
||||
COPY --from=builder /app/build /web
|
||||
|
||||
# Caddyfile configuration to serve files from /web
|
||||
RUN echo -e ":80 {\n root * /web\n file_server\n}" > /etc/caddy/Caddyfile
|
||||
|
||||
# Expose port 80
|
||||
EXPOSE 80
|
||||
|
||||
# Start Caddy with the specified Caddyfile
|
||||
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
|
5
build.sh
Executable file
5
build.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
sudo docker compose -f docker-compose.build.yml down && \
|
||||
#sudo docker compose -f docker-compose.build.yml rm --all && \
|
||||
sudo docker compose -f docker-compose.build.yml build --no-cache && \
|
||||
sudo docker compose -f docker-compose.build.yml up -d --force-recreate && \
|
||||
watch -n 1 sudo docker compose -f docker-compose.build.yml ps
|
10
docker-compose.build.yml
Normal file
10
docker-compose.build.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
web:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
no_cache: true
|
||||
ports:
|
||||
- "3000:80"
|
0
docker-compose.yml
Normal file
0
docker-compose.yml
Normal file
Loading…
Reference in a new issue