Skip to content

Commit

Permalink
Merge pull request #121 from Veinar/main
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasmtj authored Nov 20, 2023
2 parents c26c151 + c8c28cc commit a61e888
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
32 changes: 32 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Use the NODE_VERSION argument to specify the Node.js version
ARG NODE_VERSION=20

# Use the specified Node.js version as the base image
FROM node:${NODE_VERSION}-alpine

# Set Node args (do not set in node version 16 and below)
ENV NODE_OPTIONS=--openssl-legacy-provider

RUN apk add --update autoconf automake build-base libtool nasm pkgconf && \
rm -rf /var/cache/apk/*

# Setup work directory
WORKDIR /gitops-website

# Set permissions for non-root user
RUN chown -R node:node /gitops-website

# Switch user to non-root
USER node

# Add repo files with correct user:group ownership
ADD --chown=node:node . .

# Install dependencies
RUN npm ci

# Expose port for server
EXPOSE 8000

# Create entrypoint
ENTRYPOINT ["npm", "start"]
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,15 @@ npm start
yarn install
yarn start
```

**Docker setup**
```shell
# Build container image from local filesystem with default Node version
docker build --no-cache -t website:<tag> -f Containerfile .

# Build container image from local filesystem with Node version as build arg
docker build --build-arg NODE_VERSION=19 --no-cache -t website:<tag> -f Containerfile .

# Run container image with mapping port 80 on your computer
docker run -dit -p 8000:8000 website:<tag>
```
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"scripts": {
"develop": "gatsby develop",
"start": "gatsby develop",
"start": "gatsby develop --host=0.0.0.0",
"build": "gatsby build",
"serve": "gatsby serve",
"clean": "gatsby clean",
Expand Down Expand Up @@ -58,4 +58,4 @@
"postcss": "^8.3.5",
"tailwindcss": "^2.2.2"
}
}
}

0 comments on commit a61e888

Please sign in to comment.