Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docker): run optic as unprivileged user #2756

Merged
merged 6 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
FROM alpine:latest

# Doing the intial installation of Optic and Spectral separately
# saves a bit of space in the final image--Probably due to temp
# file creation.
FROM alpine:latest as dl
ARG OPTIC_CLI_VERSION=latest

RUN apk --no-cache add git curl
RUN echo "optic-docker" > /etc/machine-id
RUN apk --no-cache add curl
# install Optic
RUN set -e; sh -c "$(curl -s --location https://install.useoptic.com/install.sh)" -- $OPTIC_CLI_VERSION /usr/local/bin
# install Spectral
RUN curl -L https://raw.github.com/stoplightio/spectral/master/scripts/install.sh | sh

FROM alpine:latest
ENV INSTALLATION_METHOD="docker"
RUN addgroup -S optic && \
adduser -S optic -G optic && \
apk --no-cache add git curl && \
echo "optic-docker" > /etc/machine-id

COPY --from=dl /usr/local/bin/optic /usr/local/bin/
COPY --from=dl /usr/local/bin/spectral /usr/local/bin/

USER optic
ENTRYPOINT ["/usr/local/bin/optic"]
2 changes: 2 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ tasks:
--builder optic-multiplatform-builder
--build-arg OPTIC_CLI_VERSION={{.OPTIC_CLI_VERSION}}
.
# ensure we have the latest image pulled from the registry, easy to forget to do this
- docker pull localhost:5000/useoptic/optic:local

docker:build:release:
desc: Build an Optic image for all supported platforms, suitable for publishing
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "openapi-workspaces",
"license": "MIT",
"private": true,
"version": "0.54.7",
"version": "0.54.8",
"workspaces": [
"projects/json-pointer-helpers",
"projects/openapi-io",
Expand Down
2 changes: 1 addition & 1 deletion projects/fastify-capture/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/fastify-capture",
"license": "MIT",
"packageManager": "yarn@4.1.0",
"version": "0.54.7",
"version": "0.54.8",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/json-pointer-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/json-pointer-helpers",
"license": "MIT",
"packageManager": "yarn@4.1.0",
"version": "0.54.7",
"version": "0.54.8",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/openapi-io/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/openapi-io",
"license": "MIT",
"packageManager": "yarn@4.1.0",
"version": "0.54.7",
"version": "0.54.8",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/openapi-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/openapi-utilities",
"license": "MIT",
"packageManager": "yarn@4.1.0",
"version": "0.54.7",
"version": "0.54.8",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/optic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/optic",
"license": "MIT",
"packageManager": "yarn@4.1.0",
"version": "0.54.7",
"version": "0.54.8",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/rulesets-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/rulesets-base",
"license": "MIT",
"packageManager": "yarn@4.1.0",
"version": "0.54.7",
"version": "0.54.8",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/standard-rulesets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/standard-rulesets",
"license": "MIT",
"packageManager": "yarn@4.1.0",
"version": "0.54.7",
"version": "0.54.8",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down